Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the the replacement of setNativeProps in Fabric? #34391

Closed
tufik2 opened this issue Aug 11, 2022 · 7 comments
Closed

What is the the replacement of setNativeProps in Fabric? #34391

tufik2 opened this issue Aug 11, 2022 · 7 comments
Labels
Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@tufik2
Copy link

tufik2 commented Aug 11, 2022

Description

Hi ReactNative team, I know that in the new architecture you don't plan to give support to ref.setNativeProps.
So according to that premise, could you please give me an example of how is the new way to update the props of an element (View, TextInput) without forcing an update of the entire component?

I am looking around but don't find documentation yet and moving all to state generates performance issues...
forcing

Version

0.68.0

Output of npx react-native info

setNativeProps is not implemented in fabric

Steps to reproduce

setNativeProps is not implemented in fabric

Snack, code example, screenshot, or link to a repository

No extra data

@tufik2 tufik2 added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Aug 11, 2022
@tufik2 tufik2 changed the title Replace of setNativeProps Replace of setNativeProps? Aug 11, 2022
@tufik2 tufik2 changed the title Replace of setNativeProps? What is the the replace of setNativeProps in Fabric? Aug 11, 2022
@tufik2 tufik2 changed the title What is the the replace of setNativeProps in Fabric? What is the the replacement of setNativeProps in Fabric? Aug 11, 2022
@ecreeth
Copy link
Contributor

ecreeth commented Aug 11, 2022

FYI: https://reactnative.dev/docs/new-architecture-library-intro#migrating-off-setnativeprops Hope this helps

@tufik2
Copy link
Author

tufik2 commented Aug 12, 2022

thanks, @ecreeth but nop, the documentation said that now we are forced to move all to state, but that has a big performance impact, the idea of setNativeProp was to avoid re-render all the components and gain performance (very useful in some cases, but now without that option, we return to the previews issue, forced to re-render all the component in all cases).

@marcaaron
Copy link

that has a big performance impact, the idea of setNativeProp was to avoid re-render all the components and gain performance (very useful in some cases, but now without that option, we return to the previews issue, forced to re-render all the component in all cases)

I think the performance issue could in theory be resolved as there is no high bridge traffic cost? Still agree this is not a super ideal migration strategy. Changing an entire application's inputs from uncontrolled to controlled is a bit rough, but unsure what the alternative would be or if it would be possible to layer the setNativeProps() behavior into the JSI components?

@tufik2
Copy link
Author

tufik2 commented Sep 16, 2022

In theory, should not, but the reality is different... I was testing with Fabric enabled to see if I can migrate a library that was using setNativeProp, but I found big performance issues after moving all to state, and in theory that is expected because each time you change a value, react has to validate and figure-out what to update. The original idea of setNativeProp was to avoid all that pre-processing validations.

So if setNativeProp will not be supported I will like to know what will be the new way to update directly a value without re-validations, probable will be good to expose an internal method to do that in JSI.

@byteab
Copy link

byteab commented Mar 27, 2023

I'm also trying to create a layout animation library like framer motion that uses the FLIP technique, which basically on useLayoutEffect we should be able to use setNativeProps to reverse the current style of an Element.

@tufik2
Copy link
Author

tufik2 commented May 1, 2023

According to this merge setNativeProps should be supported, Do any person knows how to use it in fabric?

1d3fa40

@sammy-SC
Copy link
Contributor

We have added setNativeProps support to Fabric. It is available in 0.72. Closing this.

Please open a new issue if you find any problems with setNativeProps in Fabric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

6 participants