新的 react-create-app 的 react-styleguidist 错误?

react-styleguidist error for fresh react-create-app?

正在尝试为基于 React 的项目设置文档。

使用来自 'create-react-app' 的新 'my-app' 和一个非常简单的 *.js 文件我得到一个错误:

C:\xampp\htdocs\my-app2\node_modules\react-styleguidist\bin\styleguidist.js
You can now view your style guide in the browser:

  Local:            http://localhost:6060/
  On your network:  http://10.100.11.165:6060/

 FAIL  Failed to compile

./src/src/topnav/topnav.js
SyntaxError: C:\xampp\htdocs\my-app2\src\src\topnav\topnav.js: Support for the experimental syntax 'classProperties' isn't currently enabled (8:20):

   6 |  */
   7 | export default class Button extends React.Component {
>  8 |   static propTypes = {
     |                    ^
   9 |     /** Description of prop "foo". */
  10 |     foo: PropTypes.number,
  11 |     /** Description of prop "baz". */

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.
 @ ./node_modules/react-styleguidist/lib/index.js (./node_modules/react-styleguidist/loaders/styleguide-loader.js!./node_modules/react-styleguidist/lib/index.js) 46:30-89
 @ ./node_modules/react-styleguidist/lib/index.js
 @ multi ./node_modules/react-styleguidist/lib/index ./node_modules/react-styleguidist/node_modules/react-dev-utils/webpackHotDevClient.js

有人熟悉这个错误吗?

我怀疑这个修复与 Babel 有某种关系,但是,我无法从以前的查询中解决它。

@babel/plugin-proposal-class-properties添加到.babelrc并将@babel/plugin-proposal-class-properties添加到package.json,错误也说这个



.babelrc

 {
      "presets": [
        "@babel/preset-env",
        "@babel/preset-react"
      ],
      "plugins": [
        "@babel/plugin-proposal-class-properties"
       ]
    }

package.json

"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/plugin-proposal-class-properties": "^7.1.0",
...