react-phone-input icon indicating copy to clipboard operation
react-phone-input copied to clipboard

Make compatible with React 16

Open AlexChalk opened this issue 8 years ago • 6 comments

When I try to use the package with React 16, npm gives me this warning:

npm WARN [email protected] requires a peer of react@^0.14.8 || ^15.0.1 but none is installed. You must install peer dependencies yourself.

When I try to do a build with React 16, an error is thrown in the file: ./node_modules/react-phone-input/dist/index.js:

Uncaught TypeError: Cannot read property 'string' of undefined

AlexChalk avatar Oct 11 '17 19:10 AlexChalk

The fix is pretty simple, just need to add prop-types as a dependency, import PropTypes from 'prop-types' and then use it instead of React.PropTypes

But I cannot build it on my system... strange webpack errors about unexpected chars in flags.png

andreafdaf avatar Oct 17 '17 23:10 andreafdaf

@andreafdaf @adc17 I'll take a look over the weekend

sample-usr avatar Oct 18 '17 08:10 sample-usr

@razagill any progress on this?

Ok it seems that this is already fixed in master, but not yet published to npm? just peerDependencies look strange:

npm WARN [email protected] requires a peer of peerDependencies@[object Object] but none was installed.

gytisgreitai avatar Nov 22 '17 18:11 gytisgreitai

I'm having m.default.PropTypes is undefined error. I have react@16 and [email protected] and I am using PropTypes via its own package.

mgkaradag avatar Jan 24 '18 10:01 mgkaradag

@mgkaradag

This lib uses PropTypes as React.PropTypes (after bundling that syntax looks like m.default.PropTypes), but since you're using react@16 PropTypes is no longer inside React, hence the error... having prop-types as a dependency on your project doesn't change the issue

If you must use this lib you cannot use react >= 16 until it gets fixed, if you want to fix it yourself the fix is in my previous comment :v:

PS: if you can rebuild it after the fix (I couldn't, some versioning conflicts in webpack probably) could you please make a PR or publish your fork somewhere? :smile:

andreafdaf avatar Jan 25 '18 10:01 andreafdaf

This still isn't fixed

Hum4n01d avatar Jun 15 '19 02:06 Hum4n01d