React-select: Any non-typescript creatable examples?

Created on 7 Apr 2020  路  6Comments  路  Source: JedWatson/react-select

Trying to use react-select to create an input where people can add dynamic tags. Looked like the creatable examples are what I'm looking for but I couldn't seem to get them working. Is their any examples of creatables not using typescript?

Every time I add a creatable I get this error

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function 
categorquestion issureviewed

Most helpful comment

I have the same issue on using simple Select component after installing latest version using npm i react-select. If i install react-select using yarn add - the same code works fine. But my project is using npm so yarn is not an option. Thanks
Versions "react-select": "^3.1.0", "react": "^16.8.3"

All 6 comments

I have the same issue on using simple Select component after installing latest version using npm i react-select. If i install react-select using yarn add - the same code works fine. But my project is using npm so yarn is not an option. Thanks
Versions "react-select": "^3.1.0", "react": "^16.8.3"

Same for me, looks like it is a problem with npm package. Importing as es module import Select from 'react-select'; produces Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object..
In particular I think there is something wrong with default export in dist/react-select.esm.js. Because importing as cjs works: (const Select = require('react-select').default;)

Any of you figure out a fix for this?

You can try using cjs const Select = require('react-select').default;

To use Creatable?

Greetings @joshbedo

Which version are you trying to use? If you are accessing V3 then...

import Createable from "react-select/creatable";

Previous versions had a different entry-point syntax, but this is no longer valid:
import Async from 'react-select/lib/Async

Here is a codesandbox example of a CreateableSelect to help you on your way.

Let me know if this fulfills your needs or if you have other questions. I will mark this as closed, but can reopen this if there are verified issues with getting your instance to work.

Was this page helpful?
0 / 5 - 0 ratings