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

Remove defaultProps from FlatList #31798

Closed
wants to merge 13 commits into from
Closed

Remove defaultProps from FlatList #31798

wants to merge 13 commits into from

Conversation

daschaa
Copy link
Contributor

@daschaa daschaa commented Jul 1, 2021

Summary

Issue #31602. Remove defaultProps from FlatList.

Changelog

[JavaScript] [Changed] - Remove defaultProps from FlatList

Test Plan

All test for FlatList pass.

124162098-6dfe4380-da9e-11eb-9fd6-ab47820aebfa.mov

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 1, 2021
Copy link

@analysis-bot analysis-bot left a 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. Run yarn lint --fix to automatically fix problems.

Libraries/Lists/FlatList.js Outdated Show resolved Hide resolved
@analysis-bot
Copy link

analysis-bot commented Jul 1, 2021

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: fa0518d

@analysis-bot
Copy link

analysis-bot commented Jul 1, 2021

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 9,120,606 +17
android hermes armeabi-v7a 8,646,648 +22
android hermes x86 9,559,952 +18
android hermes x86_64 9,526,134 +25
android jsc arm64-v8a 10,763,210 +48
android jsc armeabi-v7a 9,680,503 +38
android jsc x86 10,797,960 +45
android jsc x86_64 11,405,635 +40

Base commit: fa0518d

@daschaa
Copy link
Contributor Author

daschaa commented Jul 6, 2021

@lunaleaps Could you review the pull request? I would be very grateful 😊

Copy link
Contributor

@lunaleaps lunaleaps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you so much for working on this! Small comments about adding more documentation in the props about defaults. Let me know if you want to add those or I can add them on land. @joxw1 Let me know your call and I'll import :)

@daschaa
Copy link
Contributor Author

daschaa commented Jul 7, 2021

Looks good, thank you so much for working on this! Small comments about adding more documentation in the props about defaults. Let me know if you want to add those or I can add them on land. @joxw1 Let me know your call and I'll import :)

I can add the documentation, no problem 😊

One thing that came up to my mind while reviewing my changes: Should I introduce a constant for all the {numColumns = 1 } assignments? Something like {numColumns = DEFAULT_NUM_COLUMNS} ? What is your opinion on that @lunaleaps ? And thank you very much for your review! 🚀

@lunaleaps
Copy link
Contributor

One thing that came up to my mind while reviewing my changes: Should I introduce a constant for all the {numColumns = 1 } assignments? Something like {numColumns = DEFAULT_NUM_COLUMNS} ? What is your opinion on that @lunaleaps ? And thank you very much for your review! 🚀

That's a good idea! I think the concern is that someone introduces a new read of the prop and doesn't set a default value. I think using a constant like that could help make it clearer if they miss it. In other work I've also created a dedicated accessor function like getNumColumnsOrDefault which serves a similar purpose.

@daschaa
Copy link
Contributor Author

daschaa commented Jul 7, 2021

One thing that came up to my mind while reviewing my changes: Should I introduce a constant for all the {numColumns = 1 } assignments? Something like {numColumns = DEFAULT_NUM_COLUMNS} ? What is your opinion on that @lunaleaps ? And thank you very much for your review! 🚀

That's a good idea! I think the concern is that someone introduces a new read of the prop and doesn't set a default value. I think using a constant like that could help make it clearer if they miss it. In other work I've also created a dedicated accessor function like getNumColumnsOrDefault which serves a similar purpose.

Done! For the naming of the accessor functions I followed the VirtualizedList class, where the accessor functions have the variable name as prefix (e.g. horizontalOrDefault(...)). Thank you very much for the nice suggestion 😊

@lunaleaps If everything fits now, will you take over the merge?

@daschaa daschaa requested a review from lunaleaps July 8, 2021 06:10
@facebook-github-bot
Copy link
Contributor

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

Libraries/Lists/FlatList.js Outdated Show resolved Hide resolved
@daschaa daschaa requested a review from lunaleaps July 8, 2021 19:28
@facebook-github-bot
Copy link
Contributor

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

Libraries/Lists/FlatList.js Outdated Show resolved Hide resolved
Joshua Wiegmann added 2 commits July 9, 2021 23:42
@daschaa daschaa requested a review from lunaleaps July 9, 2021 21:42
@facebook-github-bot
Copy link
Contributor

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

@lunaleaps lunaleaps linked an issue Jul 14, 2021 that may be closed by this pull request
@daschaa
Copy link
Contributor Author

daschaa commented Jul 17, 2021

@lunaleaps Any updates on this?

@facebook-github-bot
Copy link
Contributor

@lunaleaps merged this pull request in 7d5895d.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jul 20, 2021
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove defaultProps in FlatList
4 participants