今天在创建react项目的时候,create-react-app的时候,由于npm run eject暴露配置项
导致出现ReferenceError: React is not defined
经多方查证,
jsx 运行时的 webpack 配置会在 eject 时候被删除
所以需要在 package.json 把配置加回来,如下
"babel": {
"presets": [
[
"react-app",
{
"runtime": "automatic"
}
]
]
}
👌!