45

After upgrading React Native to 0.62.2, and installing react-native-material-dropdown` library, project is giving this error:

enter image description here

1

10 Answers 10

57

I solved this by,

  • Commenting itemTextStyle: Text.propTypes.style in
    ..\node_modules\react-native-material-dropdown\src\components\dropdown file.

  • And remove Animated in Animated.Text.propTypes.style in

    affix/index

    helper/index

    label/index

    of react-native-material-textfield.

  • And added import { Animated, Text} from 'react-native'; in each of above three files.

Sign up to request clarification or add additional context in comments.

5 Comments

Great answer but editing files under node_modules is not recommended. You can't add these files to source control since files under node_modules should be ignored. So there is no way for other developers on the same project to get the changes. And what happens if you want to upgrade to a newer version of that package? Your changes will be overwritten. A better approach would be to fork the react-native-material-dropdown package and publish a new package or get the changes integrated.
I ended up creating a new package with the fix in it, and some other improvements (like typescript definitions): react-native-material-dropdown-no-proptypes.
after editing the node_modules remember to use patch-package to patch it permanently, else the solution will be temporary
It works, thanks ! But I personnaly need to replace Animated.Text.propTypes.style by Text.propTypes
not works for me
47

Here is another solution I've found.

  1. Remove installed package react-native-material-dropdown

    yarn remove react-native-material-dropdown

  2. Install new packages react-native-material-dropdown-v2 and react-native-paper

    yarn add react-native-material-dropdown-v2 react-native-paper

  3. Swap react-native-material-dropdown to react-native-material-dropdown-v2 in your code

    e.g. import { Dropdown } from 'react-native-material-dropdown' to import { Dropdown } from 'react-native-material-dropdown-v2'

2 Comments

Problem with this solution is that even if it replaces the dropdown fix, does not fix the react-native-material-textfield package
This works like a charm!
32

I found the same problem while using @react-navigation/drawer

I've solved it by these steps.

  1. Open node_modules and then search for react-native-material-textfield open the file and go to src folder
  2. Under src you will see affix, helper, label folder - under each folder, there is an index.js
  3. open the index.js of the mentioned folders one by one (all 3 folders) and search for the text style: Animated.Text.propTypes.style, and replace it by style: Text.propTypes
  4. And import text form react-native like this import { Animated , Text} from 'react-native';
  5. And now reload the terminal, and you are good to go

5 Comments

After doing those changes, I am getting another issue: TypeError: Object is not a constructor (evaluting new TextInput({})). Any idea how to fix it?
I have solved the problem by that way which I have mentioned. And then app is working fine on my android (thought every time I have to do this after pulling from git). I would like to suggest you to uninstall the app then consider reinstalling it.
Am I really seeing this??? if you edit any file in node_modules, when you run nmp i, won't your changes be returned back to what it was???
It's a temporary solution @Whales_Corps , if you installed node_modules again then you have to make the same changes . I'm trying for a permanent solution of this. I will update it when I will find the way to do such.
And If you change once then if you do not reinstall with command npm install or sudo npm install then you can freely use this one . npm start have no link with the changes so app will run without any issue.
12

There is an issue open on github about this problem. As mentioned in the comment, it is possible to use this option to edit node modules, or create a patch so that it is not necessary to edit the files every time you add a new library or run an npm install.

Instruction:

  • Create patches directory in your project's root
  • Copy patch to patches/react-native-material-textfield+0.16.1.patch
  • yarn add patch-package postinstall-postinstall or npm i patch-package
  • yarn patch-package or npx patch-package

Fix is already applied. Add the following to package.json to not repeat the same next time:

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

https://github.com/n4kz/react-native-material-textfield/issues/249#issuecomment-625791243

Comments

3

I faced the same issue while using react-native-material-dropdown.

Fix:

  • navigate to node_modules/react-native-material-textfield/src/components
  • Open files affix/index.js, helper/index.js and label/index.js
  • Replace style: Animated.Text.propTypes.style with style: Text.propType
  • import {Text} in each of these 3 files import { Animated ,Text} from 'react-native'

This should fix the issue

react-native version: 0.64.0

Comments

2

For me it was the package "react-native-easy-toast" at version 2.0.0. The weird thing was, that I couldn't find "propTypes" or "Animated" anywhere in my Code or in my libs (node-modules). I'd expect to find it somewhere in the react-native-easy-toast folder in node_modules...

Anyway, after commenting all my toasts the app started again.

I now also found a patch for this: "https://github.com/crazycodeboy/react-native-easy-toast/issues/118" and with this and from other here mentioned patch-package it worked with the toasts and the patch gets automatically applied after npm install:)

1 Comment

same here! updated to "react-native-easy-toast": "~2.3.0" when updated to expo 46
1

Just update the library they updated their library with fixes here is the link https://www.npmjs.com/package/react-native-material-dropdown-v2-fixed

Comments

1

I am using react-native-material-textfield package, and I also faced this error so I added this piece of code in my JS file right before importing:

import { Animated, Text } from 'react-native';
Animated.Text.propTypes = Animated.Text.propTypes || Text.propTypes;
import { TextField } from 'react-native-material-textfield';

2 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
answer is clear
0

enter image description here

enter image description here

I have faced the same issue while using react-native-material-dropdown.

Fixed using this:

navigate to node_modules/react-native-material-textfield/src/components
Open files affix/index.js, helper/index.js and label/index.js

Comments

0

I have resolved my issue by using this lib

react-native-material-dropdown-no-proptypes

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.