-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ESM Support][5.7.2] Unable to use react-select in ESM project #5595
Comments
The typing issue basically boils down to: microsoft/TypeScript#50482
|
Hi, I have this problem too today whiler refresh the page. After investigate the issue, I had solved this problem by dynamic import react-select (lazy loading) using React.Suspense. Hope this clue can solve and brighten your day |
@fortezhuo Yes, I tried lazy loading yesterday and it also worked for me. |
@fortezhuo or @dziraf
And it stays stuck in Loading... |
U can add script isMounted to make sure react select only mounted on client side
If you want something more modular, u can create function to lazy loading
|
I'm seeing this too, manifesting as a lint error being thrown by
This error is thrown on 5.7.1, but not 5.7.0. Something about this setup is preventing
|
I'm seeing this too. |
There are a couple of issues we currently have with using
react-select
in our projects that use"type": "module"
inpackage.json
and have"module"
and"moduleResolution"
set to"nodenext"
intsconfig.json
.First of all, importing.
Rough example:
This now fails when building types with:
JSX element type 'ReactSelect' does not have any construct or call signatures.ts(2604)
We can resolve this ourselves by changing the above example to:
but it is not ideal.
Doing the above change allows us to build types without issue.
There is another issue which happens when we start the app though, which fails with:
The above error can be resolved by adding
"type": "module"
to everypackage.json
ofreact-select
, for example here:https://github.com/JedWatson/react-select/blob/master/packages/react-select/base/package.json
and adding
.js
extensions to exports.We managed to resolve this issue in our local environment by creating a patch:
https://gist.github.com/dziraf/160b203a8837b85a76a1f42e7b22d524
The issue still remains though as we're using it inside of one of our libraries and patches are unfortunately not installed recursively inside of
node_modules
when you install them.The text was updated successfully, but these errors were encountered: