Skip to content
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

Icon prop type error #499

Closed
simvi opened this issue Feb 8, 2023 · 4 comments
Closed

Icon prop type error #499

simvi opened this issue Feb 8, 2023 · 4 comments

Comments

@simvi
Copy link

simvi commented Feb 8, 2023

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

The type of Icon was invalid for Icon prop.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-picker-select/index.d.ts b/node_modules/react-native-picker-select/index.d.ts
index 9f111bc..09644ca 100644
--- a/node_modules/react-native-picker-select/index.d.ts
+++ b/node_modules/react-native-picker-select/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;
 }
 

This issue body was partially generated by patch-package.

marioviana pushed a commit to ThreadsStyling/react-native-picker-select that referenced this issue Feb 24, 2023
As exposed here
(lawnstarter#488)
and here
(lawnstarter#499)
we need to change teh icon type as its required to be a function
@tdraper-dev
Copy link

tdraper-dev commented Mar 9, 2023

@simvi
Do you recall if running patch-package for this library was an incredibly slow operation? I'm currently trying to run a patch on it myself and it seems like it's hanging.

@hrdyjan1
Copy link

hrdyjan1 commented Jul 17, 2023

@simvi Do you recall if running patch-package for this library was an incredibly slow operation? I'm currently trying to run a patch on it myself and it seems like it's hanging.

We were also struggling with npm, using yarn solved the problem.

@devinMcArthur
Copy link

devinMcArthur commented Aug 30, 2023

To anyone interested, this is why Icon must be a React.FC, it is being called like a component here, not a ReactNode.

If Icon was truly meant to be a ReactNode, renderIcon would look like this:

renderIcon() {
    const { style, Icon } = this.props;

    if (!Icon) {
        return null;
    }

    return (
        <View
            testID="icon_container"
            style={[defaultStyles.iconContainer, style.iconContainer]}
        >
            {Icon}
        </View>
    );
}

P.S. To get around this issue I created a Functional Component to input to Icon typed as a React.FC with a // @ts-expect-error.

@lfkwtz
Copy link
Collaborator

lfkwtz commented Nov 27, 2023

dupe of #478 - prs to fix this are welcome

@lfkwtz lfkwtz closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants