I would like to upgrade a project to React 16, because I have some dependencies that already rely on it. However, I'm also tailing a few very old React packages that I have not found the time yet to upgrade to newer releases that do support React 16. Now I need to buy some time.
My project sources have kept up with the newer releases of React, but I wonder if there's anything that would not be possible to resolve for old dependencies that would cause them to remain completely broken with React 16?
To update your React version, install the latest versions of the react and react-dom packages by running npm install react@latest react-dom@latest . If you use create-react-app , also update the version of react-scripts . Copied! The command will update the versions of the react-related packages.
Use npm outdated to discover dependencies that are out of date. Use npm update to perform safe dependency upgrades. Use npm install @latest to upgrade to the latest major version of a package. Use npx npm-check-updates -u and npm install to upgrade all dependencies to their latest major versions.
Following this suggested comment, patching React early on by importing something like the following module before importing olden dependencies should work:
import React from 'react'
import PropTypes from 'prop-types'
import createClass from 'create-react-class'
Object.assign(React, {
PropTypes,
createClass
})
For projects that were receiving warnings prior to React 16, these then get resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With