'Proptypes' is not defined

I'm setting up a new React with the help of: https://github.com/facebookincubator/create-react-app

However, I'm running into a linting issue. I'm receiving the following linting error 'PropTypes' is not defined. (no-undef).

Here is the code that is causing the issue:

import React, { Component } from 'react';
import PropTypes from 'prop-types';

class Routers extends Component {
  static propTypes = {
    history: PropTypes.object.isRequired


I tried playing around with the react/prop-types rule, but to no avail.

According to this issue comment.

It appears to be because you have installed eslint 4.x when you should just use the eslint version that is shipped with create-react-app. You should remove any eslint you have manually installed and use the one that comes with the repo.

Since react 15.5, PropTypes is included in a separate package, 'prop-types'. So this line will help

import PropTypes from 'prop-types'

You can read more here

I had the same problem on a project with eslint installed globally. I solved this case by installing eslint manualy in the project: npm i eslint --save

bye jeff

Please Install prop-types

using this code : npm install --save prop-types

You can place the PropTypes just after the class (outside the class):

Routers.propTypes = {
   history: PropTypes.object.isRequired

  • I can't see anything wrong here, are you using webpack? Can you share the config..
  • @Purgatory I believe create-react-app is using webpack. But I'm not using webpack separately.
  • Is it 'PropTypes' is not defined or 'propTypes' is not defined
  • Perhaps this issue can help? github.com/facebookincubator/create-react-app/issues/2528
  • @Purgatory 'propTypes' is not defined. Thanks I will look into it.
  • This appeared to be the issue. I ended up running npm run eject to unpack the configuration of the react-create-app package. After this I edited the package.json to use the eslint version 3.
  • thanks! fixed my issue. but why have made this changes it breaks me some compiling. when running jest
  • You can see above that he is already importing the separate prop-types package.
  • I do have the prop-types npm package installed.