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

fix flatlist props being undefined in ios #43141

Closed
wants to merge 1 commit into from

Conversation

dieguezz
Copy link
Contributor

@dieguezz dieguezz commented Feb 22, 2024

Summary:

When using Flatlist on iOS and Android its failing because props are undefined

The problem is described on #34783 #36828 #42623

Captura de pantalla 2024-02-22 a las 4 13 11

Captura de pantalla 2024-02-22 a las 4 14 58

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:

@facebook-github-bot
Copy link
Contributor

Hi @dieguezz!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Feb 22, 2024
@robhogan
Copy link
Contributor

Hi @dieguezz - thanks for working on this. Does the fix work without moving the constructor - ie just deleting line 311?

@dieguezz
Copy link
Contributor Author

dieguezz commented Feb 22, 2024

Hi @dieguezz - thanks for working on this. Does the fix work without moving the constructor - ie just deleting line 311?

Very good catch @robhogan. In fact you are right. I made the change so its one line following your advice

@facebook-github-bot
Copy link
Contributor

@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@robhogan robhogan left a 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.

@dieguezz
Copy link
Contributor Author

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

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Feb 22, 2024
@facebook-github-bot
Copy link
Contributor

@robhogan merged this pull request in e33767a.

cortinico pushed a commit that referenced this pull request Feb 26, 2024
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
okwasniewski pushed a commit to okwasniewski/react-native that referenced this pull request Mar 5, 2024
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
This was referenced Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants