-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Make AnimatedComponents and Touchables strict mode compatible #24218
Conversation
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.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
6b09f0e
to
386dc80
Compare
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.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
386dc80
to
0215319
Compare
Convert all Touchables to be class based and remove UNSAFE props. Also renamed Touchable.Mixin.withoutDefaultFocusAndBlur to Touchable.MixinWithoutDefaultFocusAndBlur to improve flow automatic typings. Note: TouchableNativeFeedback uses ReactNative.findNodeHandle which triggers a warning in strict mode during a tap. I could not figure out how to remove the need for that call. Related to facebook#22186
0215319
to
4b0c955
Compare
Will look into the test failures tomorrow. |
Thank you for this PR! Moving function calls from unsafe lifecycle methods to the constructor unfortunately doesn't actually fix any issues, it just masks them further. For Touchable, we are hoping to move those out of React Native core as part of the Lean Core effort, but first we will need to introduce a replacement. For now, we are not looking to make any larger changes to it that may break them. Would you mind sending a new PR that just fixes the |
So I should convert the animated component to use hooks too like you recommended in the scrollview PR? |
Also this might be more of a support question so I don't expect an answer, but why isn't calling attachProps from constructor the same as doing it in UNSAFE_componentWillMount? Given that it essentially only sets up the _propsAnimated value in the first pass. Note: I do see the problem with the willReceiveProps and didUpdate case (attachProps call used to run before render, now it runs after it). |
@cpojer Can you clarify the above things for me if possible |
It is the same. But I haven't looked in the code in detail so I don't know for sure whether it's a problem or not. Just moving all code from |
In particular, a PR that moves things from |
Summary
Convert all Touchables to be class based and remove UNSAFE props. Also renamed
Touchable.Mixin.withoutDefaultFocusAndBlur to Touchable.MixinWithoutDefaultFocusAndBlur
to improve flow automatic typings.
Note: TouchableNativeFeedback uses ReactNative.findNodeHandle which triggers a
warning in strict mode during a tap. I could not figure out how to remove the need for
that call.
Related to #22186
Changelog
[General] [Fixed] - Converted createAnimatedComponent to be compatible with StrictMode
[General] [Fixed] - Converted Touchable.Mixin to be compatible with StrictMode and updated built-in Touchable components.
[General] [Changed] - Renamed Touchable.Mixin.withoutDefaultFocusAndBlur to Touchable.MixinWithoutDefaultFocusAndBlur
Test Plan
Tested manually via RNTester by opening StrictMode example and ensuring no strict-mode warnings are rendered. Also made sure onPress handlers and effects still work for all of them.