Skip to content Skip to sidebar Skip to footer

Cannot Read Property 'string' Of Undefined | React.proptypes

I installed the prop-types package by running npm i prop-types --save and my dependencies are: 'dependencies': { 'prop-types': '^15.7.2', 'react': '^16.8.6', 'react-d

Solution 1:

Based on a ReactJS documentation/tutorial page, Type Checking with PropTypes, it looks like you are attempting to access PropTypes using the old approach.

Try using this instead:

Question.propTypes = {
    content: PropTypes.string.isRequired
};

Solution 2:

Looking at the documentation you don't need the React prefix:

Question.propTypes = {
  content: PropTypes.string.isRequired
};

Post a Comment for "Cannot Read Property 'string' Of Undefined | React.proptypes"