全球最全的React16版本升級手冊

升級 react , react-dom

網上有一些的講react15升級到react16升級的教程。可是不多從總體講,都是從單個知識點講。不少都是隻講react自己的升級,如:PropTypes 引用從react模塊改爲單獨的prop-types模塊。可是通常項目的架構都是:react+react-router+redux+react-redux+react-router-redux。因此本身整理一下完整的升級過程。react

react15升級到react16涉及如下幾個方面:webpack

  • 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.jsgit

  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 版本以上github

react-router 升級

react-router@3.2.0 版本以上web

相關文章
相關標籤/搜索