Skip to content
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

Can't import the named export 'useState' from non EcmaScript module #19

Open
raysk4ever opened this issue Sep 2, 2024 · 2 comments
Open
Assignees
Labels
help wanted Extra attention is needed

Comments

@raysk4ever
Copy link

Getting this error on console

Error

./node_modules/@piotr-cz/swr-idb-cache/dist/index.mjs 106:46-54
Can't import the named export 'useState' from non EcmaScript module (only default export is available)

package.json

"@piotr-cz/swr-idb-cache": "^1.1.0"

Can someone look into this issue?

@piotr-cz piotr-cz self-assigned this Sep 2, 2024
@piotr-cz
Copy link
Owner

piotr-cz commented Sep 2, 2024

Please provide package.json so I can reproduce the issue.
Problem might be that react doesn't export itself in module format, just in commonjs or that webpack doesn't process .mjs files properly.

In the meanwhile you can pin the package to latest 1.0.x:

npm install --save-exact @piotr-cz/swr-idb-cache@1.0.x

Are you using create-react-app by any chance?

The react-hook-form package had similar issue and the fixed it here: react-hook-form/react-hook-form#10486 by moving type out of tsx to ts file.

@piotr-cz
Copy link
Owner

piotr-cz commented Sep 2, 2024

Cannot reproduce with create-react-app.

You have to provide more information about your build setup so I can reproduce the issue.

@piotr-cz piotr-cz added the help wanted Extra attention is needed label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants