-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix PickerWindows (and DatePickerExample Page) #4613
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
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.
| class PickerItem extends React.Component<IPickerItemProps> { | ||
| public render(): JSX.Element | null { | ||
| return null; | ||
| throw null; |
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.
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; |
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.
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 |
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.
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] |
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.
// [Windows] [](start = 77, length = 12)
Could we remove it? It seems to bring no value.
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.
We've been using that to annotate differences in Windows patches. E.g. to ctrl+F for without opening a diff tool.
vmoroz
left a comment
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.
![]()
* 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
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