Change language to JSX in Visual Studio Code

Took me a while to figure this out but – JSX is already part of Emmet – which is part of VS Code. I've told Emmet to also (additionally) make JSX snippets available in regular JS files.

Just put this in your settings file:

"emmet.syntaxProfiles": {
    "javascript": "jsx"
}    

I would feel the below is the easiest way of formatting the code

Click on the bottom right on VS Code Editor where it says Javascript.

You will see an option to Select the language Mode, here you can search for JavaScriptReact and select. That's it. This should solve your problem.

1.Check if JavascriptReact is selected?? enter image description here


Change your user settings or workspace settings as below:

// Place your settings in this file to overwrite the default settings
{
    "files.associations": {
        "*.js": "javascriptreact"
    }
}

Note: You might need to restart VSCode.


I could do it, but "not React JS files" are also show with JavaScriptReact mode.

  1. open file C:\Program Files (x86)\Microsoft VS Code\resources\app\plugins\vs.language.javascript\syntaxes\javascriptreact.json (probably, need to open with administrator privileges.)
  2. change "jsx" to "js" in array "fileTypes".
  3. restart app, close opened js files, and reopen.