Skip to content

Instantly share code, notes, and snippets.

@bezenson
Last active September 8, 2017 15:45
Show Gist options
  • Save bezenson/a10d4cfbf1b1ef5f925253f230cd6bc7 to your computer and use it in GitHub Desktop.
Save bezenson/a10d4cfbf1b1ef5f925253f230cd6bc7 to your computer and use it in GitHub Desktop.
Move PropTypes from 'react' to 'prop-types' library fast.

If you upgraded react to latest version and got a warning Accessing PropTypes via the main React package is deprecated, and will be removed in React v16.0., but you import PropTypes from react package all over your project then check 3 simple regular expressions to find and replace in your project.

Find:

  1. (import.+)(, \{ PropTypes \})(.+'react';)$
  2. (import.+)(PropTypes, )(.+'react';)$
  3. (import.+)(, PropTypes)(.+'react';)$

Replace:

$1$3\nimport PropTypes from 'prop-types';

"Replace" string is the same for all "find" regular expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment