3

I need to enable React related suggestions and autocomplete but in files with .js extension in Visual Studio Code. The only way to make it working for me is to change extension from .js to .jsx. I tried everything described in this post but nothing worked for me.

Here is what I mean by React related suggestions and autocomplete. enter image description here

Mark Ladyshev
  • 41
  • 1
  • 3

2 Answers2

2

"*.jsx" extension assosiacted with javascriptreact language mode.

Change the file type from javascript to javascriptreact, you can do it from the bottom panel.

Or run Change language Mode from command palette (ctrl+p).

Also, you can add files.associtiations on your settings.json:

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

Language Mode

Dennis Vash
  • 50,196
  • 9
  • 100
  • 118
  • I also have tried this. But it didn't work for me, it only enables Emmet, but not giving React specific suggestions and autocomplete. It is really weird, because the only thing which can trigger enabling suggestions is when I am manually chaining file extension from `.js` to `.jsx`. Even when I am setting language mode to `javascriptreact` does not enabling suggestions. – Mark Ladyshev Jun 08 '20 at 21:36
  • This is the official way, there is no enought context to help your issue further – Dennis Vash Jun 09 '20 at 05:26
  • I have associated javascript file with javascriptreact, but [here](https://imgur.com/a/y4Xj6iz) is what I am getting. – Mark Ladyshev Jun 11 '20 at 18:12
0

I am also having same problem but when I keep index.js file open in background everything just works. You can also try

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 02 '22 at 12:27