升级react依赖
npm install react@^16.2.0
npm install react-dom@^16.2.0
npm install prop-types@^15.6.0
- 1
- 2
- 3
问题1:React.PropTypes 自 React v15.5 起已弃用。请使用 prop-types 库代替
//安装prop-types库
npm install prop-types@^15.6.0
//文件中用到React.PropTypes的地方做修改
import PropTypes from 'prop-types';
Greeting.propTypes = {
name: PropTypes.string //原为:React.PropTypes.string
};
- 1
- 2
- 3
- 4
- 5
- 6
- 7
问题2:升级react-hot-loader如果有用到
//如有此问题:Module not found: Error: Can't resolve 'react/lib/ReactMount'
npm install react-hot-loader@^3.1.3
- 1
- 2
- 3
问题3:升级react-hot-loader后wepack配置修改
/*
* Error: Module'.../node_modules/react-hot-loader/index.js'
* is not a loader (must have normal or pitch function)
*/
//webpack修改react-hot-loader ==》react-hot-loader/webpack
{
test: /\.js$/, loader:'react-hot-loader/webpack',
exclude: /node_modules/
},