Skip to content

Migrate the iOS view to a Fabric native component (codegen) #960

Backlog

Description

@Naturalclar

Overview

The iOS implementation (ios/RNCSegmentedControl.{h,m} + RNCSegmentedControlManager.m) is a legacy-architecture view manager. On the New Architecture it currently works through React Native's interop layer for legacy components. I verified this on React Native 0.88, which is New-Architecture-only, in the example app's iOS simulator build: values, images, selection, enabled, colours and the new disabledIndices all render correctly.

So nothing is broken today. But the interop layer is a migration bridge, and React Native recommends that libraries ship native Fabric components. A codegen-based component would also give type-checked native props and avoid interop overhead.

#761 implemented a Fabric component in 2023. It's useful prior art, but it can't be merged as-is:

Proposal

Re-implement the iOS view as a Fabric native component on current React Native (0.88), using #761 as a reference:

  • A codegen spec (codegenNativeComponent) covering all current iOS props: values (strings and image sources), selectedIndex, tintColor, backgroundColor, momentary, enabled, appearance, fontStyle/activeFontStyle (colour, size, family, weight), testIDS, disabledIndices, and the onChange event.
  • A Fabric component view that shares the existing UISegmentedControl logic, so the two architectures can't drift apart again.
  • A podspec using install_modules_dependencies, plus codegenConfig in package.json.

Decision needed: old architecture support

peerDependencies says react-native >= 0.62, and many apps are still on the old architecture (React Native ≤ 0.81 with the New Architecture disabled). Options:

  1. Support both architectures, with the legacy view manager kept for the old architecture. This is more code, but the change isn't breaking.
  2. New Architecture only, in a major release that raises the react-native peer range. This is simpler, but it's a breaking change.

Acceptance criteria

  • The iOS example app (React Native 0.88) renders through the Fabric component, not the interop layer, and every example section behaves as it does today.
  • Every prop listed above works on iOS, including testIDS (accessibility identifiers) and disabledIndices.
  • The old-architecture behaviour matches whichever option above is chosen.
  • CI's iOS job builds the component.

Supersedes #761.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions