ReactJS "TypeError: Cannot read property 'array' of undefined"
Prop-Types are now a separately maintained library named prop-types
Here is the explanation from react-docs: https://reactjs.org/docs/typechecking-with-proptypes.html
You have to import them as
import React from 'react';
import PropTypes from 'prop-types'
class App extends React.Component {
//App here
}
App.propTypes = {
propArray: PropTypes.array.isRequired,
propBool: PropTypes.bool.isRequired,
propFunc: PropTypes.func,
propNumber: PropTypes.number,
propString: PropTypes.string,
propObject: PropTypes.object
}
NPM Package
Change this:
App.propTypes = {
propArray: React.PropTypes.array.isRequired, //I got error over here
propBool: React.PropTypes.bool.isRequired,
propFunc: React.PropTypes.func,
propNumber: React.PropTypes.number,
propString: React.PropTypes.string,
propObject: React.PropTypes.object
}
to:
App.propTypes = {
propArray: PropTypes.array.isRequired,
propBool: PropTypes.bool.isRequired,
propFunc: PropTypes.func,
propNumber: PropTypes.number,
propString: PropTypes.string,
propObject: PropTypes.object
}`