1

When i write react code in Visual Studio Code, it is showing me error. How can i get rid of those errors?

Thanks in Advance,

Amala

Amala James
  • 1,336
  • 3
  • 16
  • 32
  • There is currently no support in VSC apart from colorisation of JSX elements: https://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/7752528-jsx-support – Henrik Andersson Dec 04 '15 at 07:43

4 Answers4

2

Go to File-> Preferences -> Workspace Settings

Then enter the following lines in settings.json file

{
    "javascript.validate.enable": false
}
manish
  • 966
  • 2
  • 11
  • 35
  • it worked if `javascript.validate.enable` is `false` :D – mayognaise Feb 04 '16 at 19:32
  • The problem with this is that it won't validate any code. Even if you are a guru, sometimes those validations help you to catch annoying little mistakes like forgetting a colon or using single quotes when React requires double quote and vice versa. – raphie Jun 13 '17 at 01:36
0

Step 1 :

Press Ctrl Shift X
It shows Extensions Screen.

Or

navigate to Extensions Screen manually

Step 2 :

Search for jsx Extension. and after result comes install Extension with name jsx.

then visual Studio code not showing error on html element.

Faraz Ahmed
  • 1,467
  • 2
  • 18
  • 33
0

First make sure you have installed all extensions for VS Code for proper code coloring and hitting for React.js, I think React-Native extensions work as well.

If you have npm installed in your system install eslint

npm install -g eslint

There is a cool add on to configure eslint to properly hitting JSX and you need to install it in your project directory. Go to your project directory on the terminal, or open the internal terminal on VS Code with the project open and type in:

npm install --save eslint-config-rallycoding

After this package is installed I suggest to create a .eslintrc file on the root of your project. This should be a proper JSON formatted code:

{
    "extends": "rallycoding"
}

save the file and then restart VSCode, just in case. This should fix those errors. The ESLint configuration package belongs to Stephen Grider, pretty sure is open source, but giving credit just in case, and I found it on a real nice tutorial on React-Native and Redux.

The Complete React Native and Redux Course

raphie
  • 3,285
  • 2
  • 29
  • 26
0

I had the same issue and I fixed it by saving the file as a .jsx.

I tried all the suggestions here but none works if the file is saved as a .js(which I think is what you are experiencing).

I am hoping a better fix is available somewhere as at this time.

twumm
  • 375
  • 1
  • 13