Closed kickbk closed 7 months ago
Any update on this? I'm getting the same issue.
I had the same issue, fixed it by updating typescript to version 4.7.3 and @types/react to 17.0.43 .
The type of Icon is React.ReactNode, but it is rendered as <Icon/>
which is a component.
However you should not create an inline component. Instead, you can create a component in the same file as
const CustomPickerIcon = () => {
return <MyIcon />;
};
...
...
...
<RNPickerSelect
...
Icon={CustomPickerIcon}
/>
@nicolaswbam that still gives me the TS error
@WahidN It's a bug of the type mentioned here https://github.com/lawnstarter/react-native-picker-select/issues/488
Passing a function or component is working in my case but why it is failing my test.
const renderIcon = () => {
return Platform.OS === "android" ? null : (
<Icon name="caretdown"
/>
);
};
<PickerSelect
Icon={renderIcon()}
{...props}
/>
I am getting:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
But if I do like bellow, the test passes but shows error. Weird part is I can run my application.
<PickerSelect
Icon={() => {
return Platform.OS === "android" ? null : (
<Ico name="caretdown" />
);
}}
{...props}
/>
I can update Icon
type from React.ReactNode
to React.FC
and everything works fine but I dont want to change node_modules file.
anyone want to open a pr for this?
I can update
Icon
type fromReact.ReactNode
toReact.FC
and everything works fine but I dont want to change node_modules file.
It's work fine.
can some of y'all review this mr?
Getting
when using like so:
Any recommendations?