-
Notifications
You must be signed in to change notification settings - Fork 25.1k
remove defaultProps from picker of components #31644
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
Conversation
Base commit: 819b926 |
Base commit: 58444c7 |
|
|
||
| exports[`<Picker /> should render as expected: should shallow render as <Picker /> when mocked 1`] = ` | ||
| <Picker | ||
| mode="dialog" |
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.
Oh interesting, I wouldn't have thought these snapshots would change. Shouldn't we still be setting the prop?
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.
Because snap only print props of passing to Picker.
After removing defaultProps,it doesn't exist in props.
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.
It should still exist in the props we pass because we're setting a default value via the destructured assignment
{mode = MODE_DIALOG...
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.
No, it is a single var rather than a part of props by destructured assignment.
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.
I think this change is expected. This test is when the component is mocked, so what shows up in the snapshot is exactly what props were passed to Picker, ignoring anything internal to picker.
The change in the test below this kinda surprises me because the title of the test says that isn't mocked. I bet something is wrong in the test there.
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.
I found that the results of mock and non-mock are the same in original snapshot, both showing the props passed to Picker.
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.
Ah I see, missed the fact that it was mocked. @kerm1it did you want to look into why the second snapshot isn't passing mode? If not, I can follow up
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.
I have explained the reason in #31644 (comment) from my opinion.
If you can follow up, I will be happy.
|
Thanks for working on this @kerm1it! Appreciate your help~ |
|
I removed |
| /* $FlowFixMe[incompatible-type] (>=0.81.0 site=react_native_ios_fb) This | ||
| * suppression was added when renaming suppression sites. */ | ||
| return <PickerIOS {...this.props}>{this.props.children}</PickerIOS>; | ||
| return <PickerIOS mode={mode} {...rest} />; |
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.
Somewhat of a nit and open for discussion but I think it'd be clearer if we kept the children as the "inner child" of this component but I don't feel strongly. We can extract it from this.props on line 170 so you can still spread rest
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.
|
|
||
| exports[`<Picker /> should render as expected: should shallow render as <Picker /> when mocked 1`] = ` | ||
| <Picker | ||
| mode="dialog" |
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.
Ah I see, missed the fact that it was mocked. @kerm1it did you want to look into why the second snapshot isn't passing mode? If not, I can follow up
|
@lunaleaps has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
@lunaleaps merged this pull request in b4cde15. |
|
There was an obvious problem: return <PickerIOS {...rest}>{children}</PickerIOS>;miss <PickerAndroid mode={mode}>{children} </PickerAndroid>miss |
Ah yup good point. I mistakenly left out the spread of |
Summary: Remove `defaultProps` from `Picker` of components, replace it with destructuring assignment. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [JavaScript] [Changed] - Remove defaultProps from picker close facebook#31603 Pull Request resolved: facebook#31644 Test Plan: all test suite and CI passes. Reviewed By: TheSavior Differential Revision: D28886320 Pulled By: lunaleaps fbshipit-source-id: d88a922dffeebe2bce019250d460b5e43a0af562

Summary
Remove
defaultPropsfromPickerof components, replace it with destructuring assignment.Changelog
[JavaScript] [Changed] - Remove defaultProps from picker
close #31603
Test Plan
all test suite and CI passes.