yarn create react-app
yarn add react-select
I created a react app using create-react-app, and it worked fine.
Then I wanted to use react-select, so I installed it with yarn, added an import statement like import Select from "react-select/src/Select";
I got this error:
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';
I can see the type keyword is causing the issue and suspect it has to do with something named flow which seems a static type checker.
What should I do to make it work?
Just import like
import Select from "react-select";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With