Reputation: 435
I am a newbie in React. I am using vscode. Whenever I save app.js file, it formats the whole code and throws errors.
I tried reinstalling vscode. I am also not using any formatting extensions. Where is it getting wrong?
Upvotes: 0
Views: 1845
Reputation: 138
As the other answer already mentioned, a prettier extension could solve the issue, but fundamentally this is because the VScode reads the program as js instead of Jsx. You can select the right language from the bottom panel as you can see from the image. So for the sake of it, I'll post how I do it as well.
Once you click that, a command pallet will open asking you to choose the language you want. Type react and choose the first option. This will clear the issues and read the program as JSX and all snippets if not working will function as well.
Upvotes: 3
Reputation: 379
Until you are comfortable with keyboard shortcuts refer following steps:
Go to File > Preferences > Settings > User > Text Editor > Formatting
Uncheck format on save option.
I would also recommend using prettier extension.
Upvotes: 1