Skip to content

Commit

Permalink
remove defaultProps from picker of components (#31644)
Browse files Browse the repository at this point in the history
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 #31603

Pull Request resolved: #31644

Test Plan: all test suite and CI passes.

Reviewed By: TheSavior

Differential Revision: D28886320

Pulled By: lunaleaps

fbshipit-source-id: d88a922dffeebe2bce019250d460b5e43a0af562
  • Loading branch information
kerm1it authored and facebook-github-bot committed Jun 5, 2021
1 parent f3b8d49 commit b4cde15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 4 additions & 6 deletions Libraries/Components/Picker/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,22 @@ class Picker extends React.Component<PickerProps> {

static Item: typeof PickerItem = PickerItem;

static defaultProps: {|mode: $TEMPORARY$string<'dialog'>|} = {
mode: MODE_DIALOG,
};

render(): React.Node {
const {mode = MODE_DIALOG, children, ...rest} = this.props;

if (Platform.OS === 'ios') {
/* $FlowFixMe[prop-missing] (>=0.81.0 site=react_native_ios_fb) This
* suppression was added when renaming suppression sites. */
/* $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 {...rest}>{children}</PickerIOS>;
} else if (Platform.OS === 'android') {
return (
/* $FlowFixMe[incompatible-type] (>=0.81.0 site=react_native_android_fb) This
* suppression was added when renaming suppression sites. */
/* $FlowFixMe[prop-missing] (>=0.81.0 site=react_native_android_fb) This
* suppression was added when renaming suppression sites. */
<PickerAndroid {...this.props}>{this.props.children}</PickerAndroid>
<PickerAndroid mode={mode}>{children} </PickerAndroid>
);
} else {
return <UnimplementedView />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ exports[`<Picker /> should render as expected: should deep render when not mocke

exports[`<Picker /> should render as expected: should shallow render as <Picker /> when mocked 1`] = `
<Picker
mode="dialog"
onValueChange={[MockFunction]}
selectedValue="foo"
>
Expand All @@ -81,7 +80,6 @@ exports[`<Picker /> should render as expected: should shallow render as <Picker

exports[`<Picker /> should render as expected: should shallow render as <Picker /> when not mocked 1`] = `
<Picker
mode="dialog"
onValueChange={[MockFunction]}
selectedValue="foo"
>
Expand Down

0 comments on commit b4cde15

Please sign in to comment.