错误

Warning: [react-router] You cannot change ; it will be ignored
Warning: [react-router] You cannot change ; it will be ignored

错误类型

这里写图片描述

原因:

// src/index.js
// Hot Module Replacement API
if (module.hot) {
  module.hot.accept();
}

看这个issues
链接1
react-transform-hmr
babel-plugin-react-transform

解决方案:

$ npm install --save-dev react-transform-hmr
$ npm install --save-dev babel-plugin-react-transform

.babelrc

{
  "presets": [ "es2015", "stage-0", "react"],
  "env": {
    "build": {
      "optional": ["optimisation", "minification"]
    },
    "development": {
      "plugins": [["react-transform", {
        "transforms": [{
          "transform": "react-transform-hmr",
          "imports": ["react"],
          "locals": ["module"] }]
      }]]
    }
  },
  "plugins": [
    ["transform-runtime"],
    ["import", {"libraryName": "antd", "style": "css"}]
  ],
  "sourceMaps": true
}
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐