TextInput.Icon: Support for defaultProps will be removed from function components in a future major release.
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.
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 |
I am facing the same. Will this deprecate ? If yes, then what I should use instead?
same issue #4386
same issue, same environment
same issue here, any way to fix this?
You can ignore the warning until the following PR is merged and released https://github.com/callstack/react-native-paper/pull/4385
i handle this warning
- go this address node_modules/react-native-paper/src/components/TextInput/Adornment/TextInputIcon.tsx
- comment These lines // TextInputIcon.defaultProps = { // forceTextInputFocus: true, // };
i handle this warning
- go this address node_modules/react-native-paper/src/components/TextInput/Adornment/TextInputIcon.tsx
- comment These lines // TextInputIcon.defaultProps = { // forceTextInputFocus: true, // };
Confirmed this works, thanks man!
If I ignore this, will the error prevent me from publishing my app?
i handle this warning
- go this address node_modules/react-native-paper/src/components/TextInput/Adornment/TextInputIcon.tsx
- comment These lines // TextInputIcon.defaultProps = { // forceTextInputFocus: true, // };
still getting same issue
Same issue
i handle this warning
- go this address node_modules/react-native-paper/src/components/TextInput/Adornment/TextInputIcon.tsx
- 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:
-
Install
patch-packageandpostinstall-postinstallas dev dependencies:yarn add patch-package postinstall-postinstall --devpostinstall-postinstallis used to ensure that patches are applied after each install. -
Create the Patch: First, modify the file
node_modules/react-native-paper/src/components/TextInput/Adornment/TextInputIcon.tsxas suggested above, see lines179-181:// TextInputIcon.defaultProps = { // forceTextInputFocus: true, // };Then, create a patch file using
patch-package. Run:npx patch-package react-native-paperThis command will generate a patch file in the
patchesdirectory with a name likereact-native-paper+<version>.patch. -
Add a Postinstall Script: Update your
package.jsonto include a postinstall script that applies the patch automatically after each install. Add the following to yourscriptssection:"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.