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

Cannot import useState because there is no useState export in react. #7489

Closed
ionutcirja opened this issue Feb 20, 2019 · 22 comments
Closed
Labels

Comments

@ionutcirja
Copy link

I just update react to latest version (16.8.2) and flow is complaining about this.

'Cannot import useState because there is no useState export in react.'.

Any plans to update flow?

Thanks

@ionutcirja ionutcirja added the bug label Feb 20, 2019
@jbrown215
Copy link
Contributor

This has already been in Flow for a few versions now. Which Flow version are you using?

@ionutcirja
Copy link
Author

0.93.0

@TrySound
Copy link
Contributor

@ionutcirja How do you import it?

@TrySound
Copy link
Contributor

Also do you have globally installed flow?

@ionutcirja
Copy link
Author

Flow is installed locally as a dev dependency.
I'm importing as it should be imported: import {useState} from 'react'

Thanks

@TrySound
Copy link
Contributor

This is weird. Could you make a screenshot with the error in terminal?

@ionutcirja
Copy link
Author

Sure, here it is.
Many thanks for your help.

screen shot 2019-02-20 at 3 57 02 pm

@jbrown215
Copy link
Contributor

Can you also run flow version and show us the output just to be sure?

@ionutcirja
Copy link
Author

Yep.
screen shot 2019-02-20 at 4 04 41 pm

@ionutcirja
Copy link
Author

Hmm, I think it might be about flow-babel-webpack-plugin.

@ionutcirja
Copy link
Author

It seems it is not. Now I'm running out of ideas.

@ionutcirja
Copy link
Author

When I'm running just flow I'm getting not errors, but something strange saying flow server didn't match the client.

screen shot 2019-02-20 at 4 46 38 pm

@jbrown215
Copy link
Contributor

Did you recently upgrade Flow? It's possible that your old server was still running and so it didn't launch a 0.93.0 server

@ionutcirja
Copy link
Author

Yes, upgraded few hours ago. Is there any way to 'clear' the old version.
I removed node modules and reinstalled already.

@jbrown215
Copy link
Contributor

flow stop

@ionutcirja
Copy link
Author

Still getting 'Cannot import useState because there is no useState export in react.' when I run webpack.

@TrySound
Copy link
Contributor

@ionutcirja You probably have flow in transitive dependencies.
https://github.com/zhirzh/flow-babel-webpack-plugin/blob/master/package.json#L8

I would get rid from this plugin. It doesn't have official support and since it's archived it doesn't have any support.

@TrySound
Copy link
Contributor

Closing as not related to flow.

@TrySound TrySound added question and removed bug labels Feb 20, 2019
@ionutcirja
Copy link
Author

Problem fixed. Many thanks for your help.

@Shettysai
Copy link

how is it fixed?

@shaantanu9
Copy link

How to fix it?

ERROR in ./src/counter.jsx 12:32-40
export 'useState' (imported as 'useState') was not found in 'react' (module has no exports)

Screenshot at 2022-03-06 21-01-58

@shaantanu9
Copy link

shaantanu9 commented Mar 6, 2022

After searching everywhere Found the Solution Use Flow as mentioned by many developers above I tried installing flow and it works

npm i -D flow-babel-webpack-plugin works for me, but

Also If that not work try once this also
"flow-bin": ">=0.44.2 <1",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants