React Native - prop-types module: Default export is not declared in imported module

Hi! In a React Native project, I get this warning:

I tried to reproduce the warning in a fresh React Native project, but in the new project the warning is not shown. So something must be different in the project where the message is shown, but I don't know what.

Any idea?

Regards, Stefan

3
9 comments

You must have prop-types typings (npm i @types/prop-types) installed in your project - node_modules/@types/prop-types/index.d.ts doesn't have any default exports declared. Try Ctrl+clicking on "prop-types" in import statement - what declaration are you taken to?

0

This is also happening for me.

 

1

I have got the same issue:

 

 

There are two folders with prop-types in my node_module
one of them is for my prop-types package 
and one of them is created (automatically) with the name of "@type" in node_modules

1

i am getting the same ... any solution yet ?

1

Try changing it to: import * as PropTypes from "prop-types";

Silly but it works!

2

yes, it's silly to import all from as PropTypes but its work for me.

There isn't a better solution for it? 

0

I would be interested in a better solution as well...

0

Maybe creating your own version of PropTypes with all the types by default. A little bit nasty but it should help IDE and your code will still look pretty.

0

I solved it by removing the package:
`yarn remove @types/prop-types`


And removing the entire folder because it was still in my node_modules:
`rm -r node_modules/@types/prop-types`

1

Please sign in to leave a comment.