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

8 comments
Comment actions Permalink

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
Comment actions Permalink

This is also happening for me.

 

1
Comment actions Permalink

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
Comment actions Permalink

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

1
Comment actions Permalink

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

Silly but it works!

1
Comment actions Permalink

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

There isn't a better solution for it? 

0
Comment actions Permalink

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

0
Comment actions Permalink

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

Please sign in to leave a comment.