-
Notifications
You must be signed in to change notification settings - Fork 501
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
Types for PickerSelectProps['Icon'] expects React.ReactNode when runtime expects a component #488
Comments
Same issue. Seems to happen since react 18 TS types. |
Facing the same issue. |
I'm using the following patch as a workaround: diff --git a/index.d.ts b/index.d.ts
index 9f111bc0fca89c51ca7a2b666959e8ad6196bd12..09644ca8b989858021913b61625c079f96331664 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -83,7 +83,7 @@ export interface PickerSelectProps {
pickerProps?: CustomPickerProps;
touchableDoneProps?: CustomTouchableDoneProps;
touchableWrapperProps?: CustomTouchableWrapperProps;
- Icon?: React.ReactNode;
+ Icon?: React.FC;
InputAccessoryView?: React.ReactNode;
}
|
@mccraveiro I am trying to patch it but it is taking forever. it keep saying installing. any idea? |
@KhimGurung no idea. What are you using to patch it? Yarn? patch-package? |
As exposed here (lawnstarter#488) and here (lawnstarter#499) we need to change teh icon type as its required to be a function
@mccraveiro - thanks for providing a fix! I couldn't get patch-package to create a patch file, so I had to manually create one. Using your example, I had to add
|
I'm having the same issue :( |
Workaround <View style={{position: 'relative'}}>
<RNPickerSelect />
<YourIcon style={{position: 'absolute', end: 12, top: 12, zIndex: -1}}/>
</View>
``` |
dupe of #478 - prs to fix this are welcome |
this works: // Create a custom select icon component import React from 'react' const DropdownIcon: React.FC = () => { return ( export default DropdownIcon; // import and use it in Component/Screen that uses the picker: |
Describe the bug
The
react-native-picker-select/index.d.ts
has a type ofReact.ReactNode
for PickerSelectProps['Icon'], but following that gives the following runtime errorPassing in a component has a type error, but works as expected during runtime
To Reproduce
In a typescript project using the following the code will give the following typescript error. Though it works at runtime
code
No overload matches this call.
Overload 1 of 2, '(props: PickerSelectProps | Readonly): Picker', gave the following error.
Type '() => JSX.Element' is not assignable to type 'ReactNode'.
Overload 2 of 2, '(props: PickerSelectProps, context: any): Picker', gave the following error.
Type '() => JSX.Element' is not assignable to type 'ReactNode'.
import RNPickerSelect from 'react-native-picker-select';
import Icon from './Icon';
const TestComponent = () => <RNPickerSelect Icon={}
The text was updated successfully, but these errors were encountered: