You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PickerStyle type definition doesn't allow for arrays of style objects to be passed for any of the properties, requiring unnecessary use of StyleSheet.flatten() to satisfy the typings. Passing arrays of style objects is valid syntax (thanks to RN StyleProp), and behaves as expected if you ignore the type errors—use of flatten shouldn't be necessary here unless the situation strictly requires it (to flatten nesting etc).
Proposed solution would be to amend the typing of the PickerStyle interface to use e.g. StyleProp<ViewStyle> instead of ViewStyle.
To Reproduce
Pass an array of ViewStyle objects into the style.inputAndroidContainer prop.
Simple reproduction can be seen with the following implementation, or on the snack linked below:
The previous typings for the `style` prop were restrictive, preventing valid passing of arrays of styles to each of the attributes.
Updating these to use `StyleProp<XStyle>` ensures valid arrays of style objects are accepted.
Fixes: lawnstarter#527
Describe the bug
The
PickerStyle
type definition doesn't allow for arrays of style objects to be passed for any of the properties, requiring unnecessary use ofStyleSheet.flatten()
to satisfy the typings. Passing arrays of style objects is valid syntax (thanks to RN StyleProp), and behaves as expected if you ignore the type errors—use of flatten shouldn't be necessary here unless the situation strictly requires it (to flatten nesting etc).Proposed solution would be to amend the typing of the PickerStyle interface to use e.g.
StyleProp<ViewStyle>
instead ofViewStyle
.To Reproduce
Pass an array of
ViewStyle
objects into thestyle.inputAndroidContainer
prop.Simple reproduction can be seen with the following implementation, or on the snack linked below:
The styles work, but a type error is raised.
Expected behavior
As the style syntax is valid, no type error should be raised.
Screenshots
Additional details
Reproduction and/or code sample
https://snack.expo.dev/@stevebutlerkyan/rnpicker-styleprop-type-error-example
The text was updated successfully, but these errors were encountered: