Cristian Muscalu
Cristian Muscalu

Reputation: 9905

How to make VSCode play nice with React syntax?

I installed all recommended extensions, still VSCode won't recognize any React syntax.

What must i do to make VSCode play nice with React (js / jsx) syntax?

enter image description here

Upvotes: 4

Views: 9875

Answers (6)

Sudaraka Senevirathne
Sudaraka Senevirathne

Reputation: 377

This happens because you use some HTML formatter, so first go to your react native or js extension settings(simple click the bottom bar language mod), and check the HTML fomatter in that setting page.

"[html]": {
    "editor.defaultFormatter": "apility.beautify-blade"
}

remove this, and you are good to go.

Upvotes: 0

Emre ACIKGOZ
Emre ACIKGOZ

Reputation: 1

1.Delete all html-js-css formatters. 2.If you want to work with this formatters, install prettier. Right click and select format document with and then select prettier. Repeat this every saving.

Upvotes: 0

Powderham
Powderham

Reputation: 1640

The plugin that was causing issues for me here actually Babel ES6/ES7 as mentioned in another comment.

Once removing that plugin and reloading, it all worked well

Upvotes: 5

Matt Bierner
Matt Bierner

Reputation: 65223

VS Code has built-in support for JSX and TSX. You do not need to install any extensions unless you want additional functionality

As the OP noted, the problem was one of their extensions was inserting spaces around the tags. I suspect it was the js css html formatter extensions since this has caused problem for people in the past

Upvotes: 4

Shaked Amar
Shaked Amar

Reputation: 243

Install Babel ES6/ES7 extension from here.

Works like charm.

enter image description here

Upvotes: -1

Andreyco
Andreyco

Reputation: 22862

Afaik, vscode does not understand JSX by default. Installing jsx plugin should help there.

Upvotes: -1

Related Questions