-
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
fix flatlist props being undefined in ios #43141
Conversation
Hi @dieguezz! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Hi @dieguezz - thanks for working on this. Does the fix work without moving the constructor - ie just deleting line 311? |
c06bf9f
to
b60835d
Compare
@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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.
Thanks again @dieguezz!
FWIW - maybe to help explain similar cases - what's happening here is that line is intended to be a pure Flow type annotation for the property on the base class, and under the default Babel settings it's stripped out completely by flow-strip-types
and has no runtime semantics.
But, when transform-class-properties
runs before flow-strip-types
(eg, with a custom Babel config), it lifts this line into the constructor and turns it into a runtime initialisation (this.props = void 0;
), which overwrites the initialisation performed in super(props)
, and effectively clobbers the props
property.
yeah that definately makes sense, in fact, i was wondering why this didn't happen before if the code of the component had not changed at all |
Summary: When using Flatlist on iOS and Android its failing because props are undefined The problem is described on #34783 ![Captura de pantalla 2024-02-22 a las 4 13 11](https://github.com/facebook/react-native/assets/1161455/325738d9-2e49-44a0-bb6a-077b2e02e9cd) ![Captura de pantalla 2024-02-22 a las 4 14 58](https://github.com/facebook/react-native/assets/1161455/118f76e1-a818-428e-938e-123b55536b49) Fixed by setting constructor before any statement and removing unnecessary props declaration at the top of the class. ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [GENERAL] [FIXED] - Fix undefined props crash in FlatList Pull Request resolved: #43141 Reviewed By: javache Differential Revision: D54069559 Pulled By: robhogan fbshipit-source-id: b39cd9a273eb0279ed353f9efcb66a3c4ccf93b4
Summary: When using Flatlist on iOS and Android its failing because props are undefined The problem is described on facebook#34783 ![Captura de pantalla 2024-02-22 a las 4 13 11](https://github.com/facebook/react-native/assets/1161455/325738d9-2e49-44a0-bb6a-077b2e02e9cd) ![Captura de pantalla 2024-02-22 a las 4 14 58](https://github.com/facebook/react-native/assets/1161455/118f76e1-a818-428e-938e-123b55536b49) Fixed by setting constructor before any statement and removing unnecessary props declaration at the top of the class. ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [GENERAL] [FIXED] - Fix undefined props crash in FlatList Pull Request resolved: facebook#43141 Reviewed By: javache Differential Revision: D54069559 Pulled By: robhogan fbshipit-source-id: b39cd9a273eb0279ed353f9efcb66a3c4ccf93b4
Summary:
When using Flatlist on iOS and Android its failing because props are undefined
The problem is described on #34783 #36828 #42623
Fixed by setting constructor before any statement and removing unnecessary props declaration at the top of the class.
Changelog:
[GENERAL] [FIXED] - Fix undefined props crash in FlatList
Test Plan: