In VSCode, how can I get auto import suggestions for React built-in hooks, like useState
, useEffect
, etc?
Just like what we get in CodeSandbox:
Enabled extensions (maybe there is some conflict between them, though I'm not getting any errors):
In VSCode, how can I get auto import suggestions for React built-in hooks, like useState
, useEffect
, etc?
Just like what we get in CodeSandbox:
Enabled extensions (maybe there is some conflict between them, though I'm not getting any errors):
So, one thing you can do is try updating your local settings file:
inside your project directory:
<project>/.vscode/settings.json
{
// other vscode settings specific to this project...
"typescript.suggest.autoImports": true, // or
"javascript.suggest.autoImports": true
}
Sometimes, extensions interfere with the functionality. With me, Vetur(Vue extension) was interfering with the React auto imports. I had to disable, and restart the VS Code. Now I can auto import from React. I enabled the Vetur again and restarted VS Code. Both Vue and React is working fine.
In the end, check if you are able to see the issue with some extension.
© 2022 - 2024 — McMap. All rights reserved.
"@types/react" and "@types/react-dom"
installed back then. You should install those. – Bathilda