Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make VS Code change language to JavaScript React when open a JSX file

Tags:

Currently, when I open a .jsx file the default language is plain JavaScript. Is there a way to set the editor to change the language based on the file extension?

Ideally, I can put this setting in both my local setting config file OR the workspace specific config file.

The version I am using is Version 1.15.0-insider (1.15.0-insider).

like image 215
X.Creates Avatar asked Aug 08 '17 02:08

X.Creates


People also ask

How do I convert JSX to JS?

There, you just have to paste your JSX code and it'll convert to equivalent Javascript for you. It's equivalent Javascript code will be: "use strict"; var App = function App() { return React.

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".

Can we use JS and JSX together?

JSX isn't necessary to use as React can be written with both JS and JSX, but JSX makes it easier for users to make React applications, as it is similar to HTML. It makes it easier to write and update HTML code, thus functionality is easier to handle.


1 Answers

Within VS Code, in the bottom right of the window you will see a smiley face - to the left of that is the language the currently visible file is associated with (e.g. JavaScript). Ensure your currently opened file is a .jsx file.

Clicking this will reveal a menu at the top. Click the Configure File Association for '.jsx'..., and then choose "JavaScript React".

like image 197
ESR Avatar answered Oct 19 '22 05:10

ESR