Reputation:
this thing has never happened to me with languages like c++, etc...
in other cases it happens but for the better, for example my html code becomes more orderly and clean.
the interesting fact that the code works. despite more than 20 errors.
Upvotes: 0
Views: 1821
Reputation: 1
change the format of the file from babel javascript to javascript react in bottom right in vs code.
Upvotes: 0
Reputation: 370729
The problem is here:
See how the filename is App.js
? That means that it will be automatically formatted for plain JavaScript.
But what you have is not plain JavaScript - you're using JSX syntax, so you need to change the file extension. Name the file app.jsx
, and make sure to change modules that import it as well if needed.
Files that contain JSX syntax should have the file extension .jsx
.
Only files that have no JSX syntax in them can be named .js
.
Another option is to change the formatter for the file to React rather than just plain JavaScript, in the bottom right, eg
but fixing the file extension is a better solution.
Upvotes: 0
Reputation: 8412
You probably apply the wrong format to your code
You will need to change your formater or turn auto format onsave
off:
Add the following to your settings.json file:
"editor.formatOnSave": true
Upvotes: 1