AdamG AdamG - 3 years ago 214
React JSX Question

How to find cause of Warning: PropTypes has been moved to a separate package

If I get the warning "Warning: PropTypes has been moved to a separate package." How can I locate which npm package is still using it? The warning doesnt offer any details about what file or package is causing it.

enter image description here

Answer Source

React deprecated the usage of propTypes from their main package so you can't use React.PropTypes. When you use React.PropTypes it gives you a warning but when you use propTypes from prop-types package you are good.

That's It :)

You can use this knowledge to find the list of npm package which is using it through the following command.

find ./node_modules -type f -print0 | xargs -0 grep 'PropTypes' | cut -d/ -f3 | sort | uniq | xargs -I{} grep -L 'prop-types' ./node_modules/{}/package.json

The above command will find all the npm packages having PropTypes word present in any of their files, then it looks into the package.json file of that package to check whether the prop-types package is included or not. If prop-types package is missing then it prints the path of that package.

PS: I'm no bash expert so I've taken little help from this serverfault answer. (To find the unique npm packages containing the PropTypes word)

enter image description here

PPS: The answer assumes that you are using a Unix machine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download