Skip to content

Conversation

@NickGerleman
Copy link
Contributor

@NickGerleman NickGerleman commented Apr 15, 2020

Fixes #4597

Our implementation of Picker is a bit deformed. In Stock React Native, Picker.js will delegate to PickerAndroid and PickerIOS. In Windows, we the two are copy pasted. In 0.62, invariants are added to prevent duplicate view manager registration. We run into issues with this with Picker, since our copies will both call requireNativeComponent. This change modifies the normal picker to delegate to PickerWindows to work correctly from the stock picker. I.e. The stock picker's child views are meant for data only and will throw if rendered, where the Windows version's are included but used to noop render.

Picker is getting lean-cored, so I didn't invest much into fixing PickerWindow's isssues, converting to Flow, NativeComponent strucutre, etc.

Validated Picker, PickerWindows, DatePicker RNTester pages work correctly.

Microsoft Reviewers: Open in CodeFlow

Fixes microsoft#4597

Our implementation of Picker is a bit deformed. In Stock React Native, Picker.js will delegate to PickerAndroid and PickerIOS. In Windows, we the two are copy pasted. In 0.62, invariants are added to prevent duplicate view manager registration. We run into issues with this with Picker, since our copies will both call requireNativeComponent. This change modifies the normal picker to delegate to PickerWindows to work correctly from the stock picker. I.e. The stock picker's child views are meant for data only and will throw if rendered, where the Windows version's are included but used to noop render.

Picker is getting lean-cored, so I didn't invest much into fixing PickerWindow's isssues, converting to Flow, NativeComponent strucutre, etc.

Validated Picker, PickerWindows, DatePicker RNTester pages work correctly.
@NickGerleman NickGerleman requested a review from a team as a code owner April 15, 2020 14:31
class PickerItem extends React.Component<IPickerItemProps> {
public render(): JSX.Element | null {
return null;
throw null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

throw null is kind of crazy, but matches upstream behavior/behavior in Picker.js

const props = {...this.props};
props.onStartShouldSetResponder = () => true;
props.onResponderTerminationRequest = () => false;
props.style = this.props.style;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line doesn't seem to do anything useful. We already do a shallow clone of props including props.style with const props = {...this.props}; above.

props.onStartShouldSetResponder = () => true;
props.onResponderTerminationRequest = () => false;
props.style = this.props.style;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a setting to disable this check when adjacent to the rest parameter that's off by default, but not in stock RN eslint rules that we're using apparently. I'd be fine changing that as well.

);
} else if (Platform.OS === 'windows') {
return (
<PickerWindows {...this.props}>{this.props.children}</PickerWindows> // [Windows]
Copy link
Member

@vmoroz vmoroz Apr 15, 2020

Choose a reason for hiding this comment

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

// [Windows] [](start = 77, length = 12)

Could we remove it? It seems to bring no value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We've been using that to annotate differences in Windows patches. E.g. to ctrl+F for without opening a diff tool.

Copy link
Member

@vmoroz vmoroz left a comment

Choose a reason for hiding this comment

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

:shipit:

@NickGerleman NickGerleman merged commit e0adf5e into microsoft:master Apr 15, 2020
asklar pushed a commit to asklar/react-native-windows that referenced this pull request Apr 19, 2020
* Fix PickerWindows (and DatePickerExample Page)

Fixes microsoft#4597

Our implementation of Picker is a bit deformed. In Stock React Native, Picker.js will delegate to PickerAndroid and PickerIOS. In Windows, we the two are copy pasted. In 0.62, invariants are added to prevent duplicate view manager registration. We run into issues with this with Picker, since our copies will both call requireNativeComponent. This change modifies the normal picker to delegate to PickerWindows to work correctly from the stock picker. I.e. The stock picker's child views are meant for data only and will throw if rendered, where the Windows version's are included but used to noop render.

Picker is getting lean-cored, so I didn't invest much into fixing PickerWindow's isssues, converting to Flow, NativeComponent strucutre, etc.

Validated Picker, PickerWindows, DatePicker RNTester pages work correctly.

* Change files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(0.62) Exception thrown any time pickers are imported

2 participants