Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error trying to import react-select to a project created with create-react-app

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?

like image 880
akanosenritu0 Avatar asked Sep 01 '26 11:09

akanosenritu0


1 Answers

Just import like

import Select from "react-select";
like image 68
Kid Avatar answered Sep 03 '26 00:09

Kid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!