Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React/JSX support in WebStorm?

I cannot get JSX support in WebStorm. That is, it does not recognise JSX in react component render methods. It just looks like this to me :

enter image description here

Apparently it is possible, and there is some documentation on the web :

https://blog.jetbrains.com/webstorm/2015/10/working-with-reactjs-in-webstorm-coding-assistance/

It states that you should use JSX Harmony which can be found in Preferences | Languages & Frameworks | JavaScript.

But in my version of WebStorm (i.e. the latest 2016.3) there is no such checkbox for JSX Harmony. There is something called JSX Emmet which is already checked by default... but does not help.

like image 540
Oliver Watkins Avatar asked Mar 29 '17 16:03

Oliver Watkins


2 Answers

I just realised that there is a Javascript language version drop down which you have to change to React JSX. It wasn't clear to me in the documentation, or the 'search' field in the Settings window.

Basically you have to do the following :

enter image description here

And you are done :)

like image 120
Oliver Watkins Avatar answered Nov 19 '22 12:11

Oliver Watkins


I was able to create .jsx files, but in the next session WebStorm didn't recognize it anymore. Override File Type did solve the issue for me.

File menu Override file type

Another option is to create a file without an extension and use the automatic dialog to associate the type: File type association

like image 2
Alex Semykin Avatar answered Nov 19 '22 13:11

Alex Semykin