create-react-app 构建的项目使用 mobx

Posted zhourongcode

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了create-react-app 构建的项目使用 mobx相关的知识,希望对你有一定的参考价值。

在 create-react-app 命令行构建的 React 项目中使用 Mobx 会出现如下警告:

Support for the experimental syntax ‘decorators-legacy‘ isn‘t currently enabled (9:5):

需要启用 ESNext 的装饰器 (命令行中执行 mac 端)

  1. 先 git add .
  2. git commit -am "Save before ejecting" (然后(注意这里是 am)
  3. npm run eject
  4. 在 package.json 里 babel 添加
 "babel": {
    "presets": [
      "react-app"
    ],
    "plugins": [
      "transform-decorators-legacy"
    ]
  • npm install --save-dev babel-plugin-transform-decorators-legacy (安装该模块中间可能有告警自行消除即可)

按照以上步骤就可以开心的使用 Mobx

以上是关于create-react-app 构建的项目使用 mobx的主要内容,如果未能解决你的问题,请参考以下文章

create-react-app 构建的项目使用代理 proxy

使用 create-react-app 快速构建 React 开发环境

React使用 create-react-app 快速构建 React 开发环境

create-react-app 构建的项目使用 css module 方式来书写 css

使用Facebook的create-react-app脚手架快速构建React开发环境(ant.design,redux......)

为啥我在使用 create-react-app 的生产构建中丢失了 Bootstrap 样式?