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

refactor: remove DefaultProps from the StatusBar Component #31631

Closed
wants to merge 4 commits into from
Closed

refactor: remove DefaultProps from the StatusBar Component #31631

wants to merge 4 commits into from

Conversation

Fannolo
Copy link

@Fannolo Fannolo commented May 29, 2021

Summary

Issue #31607. defaultProps makes it difficult to migrate components to functional.

Changelog

[General] [Changed] - Remove defaultProps from the StatusBar Component.

Test Plan

Verified the behaviour of the existing functionality after the removal on the RN Tester app.

Screen.Recording.2021-05-30.at.00.03.38.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 May 29, 2021
@analysis-bot
Copy link

analysis-bot commented May 29, 2021

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

Base commit: e24b55e

@lunaleaps lunaleaps self-assigned this May 31, 2021
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.

We want to remove defaultProps from the component but still want the default value to be applied. Right now, whenever you use props.animated or props.showHideTransition, the value will be undefined if a user does not supply the prop. We need to make sure all access of these props still have a default value -- we just don't want to use React's defaultProps construct to ensure that.

Please add a snapshot test as well to verify these props. You can take a look at how VirtualizedList does Jest snapshots.
Let me know if that makes sense!

@lunaleaps lunaleaps linked an issue May 31, 2021 that may be closed by this pull request
@Fannolo
Copy link
Author

Fannolo commented Jun 4, 2021

Hi @lunaleaps! Thank you for your suggestion! I just made a new commit could you take a look at it and see if that's what you had in mind? I added default value to the animated prop and showHideTransition prop whenever createStackEntry is called, so when you have animated or showHideTransition set to undefined, the values will be automatically set to false and "fade" respectively.

@lunaleaps
Copy link
Contributor

lunaleaps commented Jun 5, 2021

@Fannolo Great thank you! Would you also be interested in writing a jest test for this component? You can take a look at VirtualizedList-test as an example: https://github.com/facebook/react-native/blob/dc80b2dcb52fadec6a573a9dd1824393f8c29fdc/Libraries/Lists/__tests__/VirtualizedList-test.js

you can check out the Jest API:
and run the the test via

yarn test [name of your test]

@Fannolo
Copy link
Author

Fannolo commented Jun 13, 2021

@Fannolo Great thank you! Would you also be interested in writing a jest test for this component? You can take a look at VirtualizedList-test as an example: https://github.com/facebook/react-native/blob/dc80b2dcb52fadec6a573a9dd1824393f8c29fdc/Libraries/Lists/__tests__/VirtualizedList-test.js

you can check out the Jest API:
and run the the test via

yarn test [name of your test]

Hi @lunaleaps, I added some tests to the StaturBar component could you take a look and see if I'm going on the right direction? Thanks!

@lunaleaps
Copy link
Contributor

lunaleaps commented Jun 16, 2021

@Fannolo Yup! That looks great! Great to assert that the value of the prop is set to its default if not passed in. You can also try running your tests before and after your changes to see if anything has changed. Let me know when you're ready for review again. You can "request changes" from me

@Fannolo
Copy link
Author

Fannolo commented Jul 27, 2021

Hi @lunaleaps sorry for the long wait, I checked if the tests were working with the old version of the code and everything looks fine! Lemme know if you can review the pull request!

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

@facebook-github-bot
Copy link
Contributor

@lunaleaps merged this pull request in 5923ee5.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Aug 18, 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. Needs: Author Feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove defaultProps from StatusBar
4 participants