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?
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.
Open that JavaScript file. On the bottom left You can see the language"JavaScript". Click on it and select "JavaScript React".
JSX is an extension of the JavaScript language based on ES6, and is translated into regular JavaScript at runtime.
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”.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With