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

TextInput.Icon: Support for defaultProps will be removed from function components in a future major release. #4382

Closed
yannick-softwerft opened this issue Apr 24, 2024 · 11 comments
Labels

Comments

@yannick-softwerft
Copy link

yannick-softwerft commented Apr 24, 2024

Current behaviour

Warning: TextInput.Icon: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.

Expected behaviour

No warning.

image

Your Environment

software version
react-native 0.74.0
react-native-paper 5.12.3
node 18.18.0
npm or yarn 9.8.1
expo sdk No Expo
@choudhary-github
Copy link

I am facing the same. Will this deprecate ? If yes, then what I should use instead?

@zkteco-home
Copy link

same issue #4386

@sa1utep1z
Copy link

same issue, same environment

@keehui9292
Copy link

same issue here, any way to fix this?

@raajnadar
Copy link
Collaborator

You can ignore the warning until the following PR is merged and released #4385

@pooria226
Copy link

i handle this warning

  1. go this address node_modules/react-native-paper/src/components/TextInput/Adornment/TextInputIcon.tsx
  2. comment These lines
    // TextInputIcon.defaultProps = {
    // forceTextInputFocus: true,
    // };

@dillontl
Copy link

dillontl commented Jul 3, 2024

i handle this warning

  1. go this address node_modules/react-native-paper/src/components/TextInput/Adornment/TextInputIcon.tsx
  2. comment These lines
    // TextInputIcon.defaultProps = {
    // forceTextInputFocus: true,
    // };

Confirmed this works, thanks man!

@Donald646
Copy link

If I ignore this, will the error prevent me from publishing my app?

@hashreepriya
Copy link

i handle this warning

  1. go this address node_modules/react-native-paper/src/components/TextInput/Adornment/TextInputIcon.tsx
  2. comment These lines
    // TextInputIcon.defaultProps = {
    // forceTextInputFocus: true,
    // };

still getting same issue

@intentodepirata
Copy link

Same issue

@ttebify
Copy link

ttebify commented Aug 19, 2024

i handle this warning

  1. go this address node_modules/react-native-paper/src/components/TextInput/Adornment/TextInputIcon.tsx
  2. comment These lines
    // TextInputIcon.defaultProps = {
    // forceTextInputFocus: true,
    // };

Before this current PR is merged and you really need this update up, you can use patch-package to apply a patch to the react-native-paper package, follow these steps:

If you are using yarn:

  1. Install patch-package and postinstall-postinstall as dev dependencies:

    yarn add patch-package postinstall-postinstall --dev

    postinstall-postinstall is used to ensure that patches are applied after each install.

  2. Create the Patch:
    First, modify the file node_modules/react-native-paper/src/components/TextInput/Adornment/TextInputIcon.tsx as suggested above, see lines 179-181:

    // TextInputIcon.defaultProps = {
    //   forceTextInputFocus: true,
    // };

    Then, create a patch file using patch-package. Run:

    npx patch-package react-native-paper

    This command will generate a patch file in the patches directory with a name like react-native-paper+<version>.patch.

  3. Add a Postinstall Script:
    Update your package.json to include a postinstall script that applies the patch automatically after each install. Add the following to your scripts section:

    "scripts": {
      "postinstall": "patch-package"
    }

    This script will ensure that your patches are applied after every yarn install.

You can verify your patch by installing the package again and checking if the changes you made are correctly applied to the node_modules directory. The lines should be commented out in TextInputIcon.tsx.

Remember to remove the patch after the fix to this issue has been released as a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests