react-native-picker / picker

Picker is a cross-platform UI component for selecting an item from a list of options.
MIT License
1.47k stars 277 forks source link

feat: add Fabric support #456

Closed WoLewicki closed 9 months ago

WoLewicki commented 1 year ago

PR adding Fabric support to the library. Android code regarding handling state on Fabric has been mainly taken from react-native-screens repo (Screen component).

As for the JS code, I have changed the implementation to functional style components, based mainly on Switch: https://github.com/facebook/react-native/blob/5dd2f2e4b7669397f8bfa9b3845afee7e4e47626/Libraries/Components/Switch/Switch.js. It was done like this since Fabric introduces some changes in how the render/layout phases work, leading to jumping layout when native commands (substitute for setNativeProps on Fabric) were called in the event callback (see attached video). Now the native event changes the state of component, leading to a rerender and call of useLayoutEffect, where there is a chance of reverting the native change.

https://user-images.githubusercontent.com/32481228/204032697-c478007f-3e4d-4f9f-8e3a-98b6f3d3dba8.mp4

Coauthored by @j-piasecki.

kevin-williams commented 1 year ago

Any update to this PR?

I have a release I want to get to prod for our company because fabric makes the app so much faster. This is one of my last TODOs on the upgrade. If the PR is soon I'll wait.

Thanks!

Korin92 commented 1 year ago

Doesn't support Fabric yet?

gtomitsuka commented 1 year ago

Hey, are there any remaining milestones on the JS or iOS side? Happy to support!

We could push this to a feature branch for easier beta testing & further work by more contributors

efstathiosntonas commented 1 year ago

Hey folks, are there any updates on this? Thanks

WoLewicki commented 1 year ago

I think it's up to @Naturalclar to decide what to do with it.

dmk3141618 commented 11 months ago

Any updates? Nowadays most of RN codes are based on the Fabric new architecture. Can I only use this on the old architecture?

It seems I can not use only this package on the old architecture because I can only select one architecture with compile level option.

aos : gradle.properties > newArchEnabled=true ios : RCT_NEW_ARCH_ENABLED=1 npx pod-install ios

Louis-C7 commented 10 months ago

Any update?

j-piasecki commented 9 months ago

@Naturalclar Are there any plans to merge this PR?

WoLewicki commented 9 months ago

It should be ready @Naturalclar :rocket: Would be really nice to merge it and release so people can check if everything works fine.

Naturalclar commented 9 months ago

:tada: This PR is included in version 2.6.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: