Accessing PropTypes via the main React package is deprecated Accessing PropTypes via the main React package is deprecated reactjs reactjs

Accessing PropTypes via the main React package is deprecated


As others have mentioned- if you have audited your own project for PropTypes uses but you're still seeing the warning- it's likely coming from an upstream dependency. One way you can track down the cause of this warning is by setting a debug breakpoint where it's logged and then stepping back to the caller. Here's a quick example recording I made:

enter image description here

(A higher-quality version is available here.)

Once you've identified the library in question, consider filing a Github issue (or better yet- a PR!) to inform the authors of the new warning.

In the meanwhile, this is only a dev-mode warning so it should not affect production usage of your application.


Since the release of React v15.5.0 React.PropTypes is deprecated and has moved to another library. You should use npm install prop-types and use PropTypes from there.

The code at ./components/containers/Scorboard.js looks perfectly fine, you probably have a React.PropTypes somewhere else in your code.

Another options is that some dependency that you are using is still using it the old way. You can try to update your dependencies but as this deprecation is quite new I doubt that every library had already released an update.

More details about the PropTypes deprecation here.

UPDATE

It seems like redux has updated it's dependencies to use React v15.5.0 and got rid of the deprecation warnings. It is fixed in v4 and v5 as well.

Relevant pull requests: #663 and #666


I solved this warning this way:

Installed PropTypes

# npm install -S prop-types

Import PropTypes like this

import PropTypes from 'prop-types';

instead of doing this:

import { PropTypes } from 'react';