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

发布时间:2019-06-05 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了全球最全的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') {
    @H_304_39@// _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 版本以上

脚本宝典总结

以上是脚本宝典为你收集整理的全球最全的React16版本升级手册全部内容,希望文章能够帮你解决全球最全的React16版本升级手册所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。