-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[RFC: Docs] Add DirectManipluation guide to explain setNativeProps #1656
Conversation
the browser for example, you sometimes need to directly modify a DOM | ||
node. This could be necessary for a variety of reasons, such as | ||
performance (avoid a render pass, useful with animations) or to simplify | ||
the API of a component. Both of these apply to `TouchableOpacity`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setNativeProps is best used for continuous animations, to avoid the overhead of rendering the component hierarchy and reconciling many views. I believe we want to discourage it from an API perspective since it is imperative and stores state in the native layer (DOM, UIView, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 should have mentioned the continuous animations use case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also should be sure to emphasize more that this shouldn't be something that you use frequently outside of that use case
Random nitpick: At a higher level, I would change the framing of "Only use this if you really need to" to more of a "When to use this and when not to and why not". I generally agree with @ide that performance is the main reason to use it, and that you are trading off complexity of implementation for small -- but sometimes critically important -- gains in UI smoothness, etc. Overall, I think this is awesome! I think that this will go along way to making bits of React Native less mysterious and get more people building good stuff on it. |
Great point @ccheever - updated accordingly |
[Docs] Add DirectManipluation guide to explain setNativeProps
If someone could read this over and give me some feedback it would be much appreciated.
Addresses #1390