We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Item.value
Describe the bug The type of Item.value, PickerSelectProps.value and PickerSelectProps.onValueChange don't line up with @react-native-picker/picker.
@react-native-picker/picker
At the moment, the type of Item.value is any but it should be number | string , see https://github.com/react-native-picker/picker/blob/v2.4.8/typings/Picker.d.ts#L12.
any
number | string
Also, the default placeholder value shouldn't be null anymore.
null
To Reproduce N/A
Expected behavior The type should match @react-native-picker/picker, otherwise it's misleading as any implies that I can pass in object but it won't work if I do.
object
Here is what I am using for now.
diff --git a/node_modules/react-native-picker-select/index.d.ts b/node_modules/react-native-picker-select/index.d.ts index 1760dbc..03a20b8 100644 --- a/node_modules/react-native-picker-select/index.d.ts +++ b/node_modules/react-native-picker-select/index.d.ts @@ -9,9 +9,9 @@ import { import React from 'react'; import { PickerProps } from '@react-native-picker/picker/typings/Picker'; -export interface Item { +export interface Item<T extends string | number> { label: string; - value: any; + value: T; key?: string | number; color?: string; /** @@ -66,11 +66,11 @@ type CustomTouchableDoneProps = Omit<TouchableOpacityProps, 'onPress'>; type CustomTouchableWrapperProps = Omit<TouchableOpacityProps, 'onPress'>; // 'testID' and 'activeOpacity' are also used, but can be overwritten safely -export interface PickerSelectProps { - onValueChange: (value: any, index: number) => void; - items: Item[]; - value?: any; - placeholder?: Item | {}; +export interface PickerSelectProps<T extends string | number> { + onValueChange: (value: Item<T>['value'], index: number) => void; + items: Item<T>[]; + value?: Item<T>['value']; + placeholder?: Item<T> | {}; disabled?: boolean; itemKey?: string | number; style?: PickerStyle; @@ -93,7 +93,7 @@ export interface PickerSelectProps { darkTheme?: boolean; } -declare class Picker extends React.Component<PickerSelectProps> { +declare class Picker<T extends string | number> extends React.Component<PickerSelectProps<T>> { togglePicker: (animate?: boolean, postToggleCallback?: () => void) => void; }
Screenshots N/A
Additional details
Reproduction and/or code sample N/A
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
The type of Item.value, PickerSelectProps.value and PickerSelectProps.onValueChange don't line up with
@react-native-picker/picker
.At the moment, the type of
Item.value
isany
but it should benumber | string
, see https://github.com/react-native-picker/picker/blob/v2.4.8/typings/Picker.d.ts#L12.Also, the default placeholder value shouldn't be
null
anymore.To Reproduce
N/A
Expected behavior
The type should match
@react-native-picker/picker
, otherwise it's misleading asany
implies that I can pass inobject
but it won't work if I do.Here is what I am using for now.
Screenshots
N/A
Additional details
Reproduction and/or code sample
N/A
The text was updated successfully, but these errors were encountered: