0

Any idea how to enable auto import suggestion inside jsx ?

Inside jsx

This is weird because if I'm typing outside of the jsx, it gives me the auto import suggestion.

Outside jsx

I'm not installing any snippets or Auto Import Extension, or Visual Studio IntelliCode.

But even though I installed them, it doesn't help this issue.

Mark
  • 143,421
  • 24
  • 428
  • 436
Han
  • 51
  • 3
  • 4

2 Answers2

0

This issue: Auto-imports from within jsx don't work will apparently be fixed in vscode v1.58.

https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_58.md#typescript-435

TypeScript 4.3.5

We now bundle TS 4.3.5. This minor update fixes a few important bugs, including auto imports not working in JSX.

Mark
  • 143,421
  • 24
  • 428
  • 436
0

For me, I added the below code in settings.json and It worked.

"files.associations": {
    "*.jsx": "javascriptreact",
    "*.js": "javascriptreact"
}

If you want to have react in JS files, you can add the below code

// FOR THE HTML EMMET IN REACT BELOW
"emmet.includeLanguages": {
    "javascript": "javascriptreact"
},
Zia Khaan
  • 1
  • 2