升级React16

升级react依赖

npm install react@^16.2.0
npm install react-dom@^16.2.0
npm install prop-types@^15.6.0

问题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
};

问题2:升级react-hot-loader如果有用到

//如有此问题:Module not found: Error: Can't resolve 'react/lib/ReactMount'
npm install react-hot-loader@^3.1.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/
},
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lzr_must/article/details/79979377
文章标签: js react16
个人分类: react
上一篇express中间件模拟实现
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭