yarn create react-app
yarn add react-select
我使用 create-react-app 创建了一个反应应用程序,它运行良好。然后我想使用react-select,所以我用yarn安装了它,添加了一个import语句,比如import Select from "react-select/src/Select";
我收到了这个错误:
Failed to compile.
./node_modules/react-select/src/Select.js
SyntaxError: ~~~~\node_modules\react-select\src\Select.js: Unexpected token, expected "," (3:32)
1 | // @flow
2 |
> 3 | import React, { Component, type ElementRef, type Node } from 'react';
| ^
4 | import memoizeOne from 'memoize-one';
5 | import { MenuPlacer } from './components/Menu';
6 | import isEqual from './internal/react-fast-compare';
我可以看到type关键字导致了问题,并怀疑它与命名的东西有关flow,它似乎是一个静态类型检查器。我应该怎么做才能让它工作?