全球最全的React16版本升级手册

升级 react , react-dom

网上有一些的讲react15升级到react16升级的教程。但是很少从整体讲,都是从单个知识点讲。很多都是只讲react本身的升级,如:PropTypes 引用从react模块改成单独的prop-types模块。但是一般项目的架构都是:react+react-router+redux+react-redux+react-router-redux。所以自己整理一下完整的升级过程。

react15升级到react16涉及以下几个方面:

  • react-hot-loader
  • proptypes
  • react-redux
  • react-router

react-hot-loader 升级

  • react-hot-loader 升级最新
  • webpack.base.conf.js
if (env === 'development') {
    // _loaders.unshift('react-hot');
}
  • .babelrc 增加react-hot-loader配置
"plugins": [
    "react-hot-loader/babel"
]

proptypes 调整

React-PropTypes-to-prop-types.js

  1. Go to the /web directory on your project
  2. npm install global add jscodeshift, this will add jscodeshift
  3. git clone https://github.com/reactjs/re... this will add react-codemod
  4. cd react-codemod && npm install cd ..
  5. jscodeshift -t <codemod-script> <path> to transform your deprecated code. For example, if you want to fix prop-types errors in jsx files in the components directory, you can run something like: jscodeshift -t react-codemod/transforms/React-PropTypes-to-prop-types.js app/components/**/*

react-redux 升级

react-redux@5.0.6 版本以上

react-router 升级

react-router@3.2.0 版本以上

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值