Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React prop-types error

I'm trying to create web app in codepen. I'm using React, ReactDOM. All was fine. But when I added react-router-dom to my project, I got an error:

react-router-dom.min.js:1 Uncaught Error: Cannot find module "prop-types"

How can I fix this?

like image 235
Leonid Gordun Avatar asked Apr 11 '17 22:04

Leonid Gordun


2 Answers

As of React 15.5.0, PropTypes have been removed from the core React package as a separate dependency. To fix this, add prop-types into your code:

If you're loading via script tags:

<script src="https://unpkg.com/prop-types/prop-types.min.js"></script>

Or via NPM:

npm install --save prop-types
like image 93
Yangshun Tay Avatar answered Oct 25 '22 22:10

Yangshun Tay


Looks like the lates UMD build at:

<script src="https://unpkg.com/react-router-dom/umd/react-router-dom.min.js"></script>

is currently missing a dependence on prop-types. You can use version 4.0.0 instead for the time being to avoid this error:

 <script type="text/javascript" src="https://unpkg.com/[email protected]/umd/react-router-dom.min.js"></script>
like image 38
Bill Healey Avatar answered Oct 25 '22 23:10

Bill Healey