Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change language to JSX in Visual Studio Code

Visual Studio Code now supports JSX on 0.8 version, but looks like the only way to activate it is with a .jsx file extension. It is not on the list to change the language mode manually, the nearest option is JavaScriptReact, but it doesn't parse the JSX tags.

I'm in a project with a lot of .js files with JSX and I can't change it.

Is there any other way to use JSX syntax without the .jsx extension?

like image 934
William Grasel Avatar asked Sep 28 '15 21:09

William Grasel


People also ask

How do I change the language mode in Visual Studio code?

Press Ctrl+Shift+P to bring up the Command Palette then start typing "display" to filter and display the Configure Display Language command. Press Enter and a list of installed languages by locale is displayed, with the current locale highlighted.

How do you switch to React in VS code?

Open that JavaScript file. On the bottom left You can see the language"JavaScript". Click on it and select "JavaScript React".

How is JSX translated?

JSX is an extension of the JavaScript language based on ES6, and is translated into regular JavaScript at runtime.

Is JSX a React only language?

It is called JSX, and it is a syntax extension to JavaScript. We recommend using it with React to describe what the UI should look like. JSX may remind you of a template language, but it comes with the full power of JavaScript. JSX produces React “elements”.


1 Answers

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.

like image 122
Dionys Avatar answered Oct 29 '22 23:10

Dionys