React JSX error : Unclosed regular expression

匿名 (未验证) 提交于 2019-12-03 02:54:01

问题:

Recently I was facing an i was facing an issue coding React app on Visual Studio code. Because of this issue, whenever I wrote JSX inside the render function of the React Component and saved it, it would go messed up (I mean indentation would get messy). See the pic:

This error was also showing error like: 1. Unclosed regular expression

How to solve this?

回答1:

I tried several options like creating a .eslintrc file or .jshintrc file.

But it turned out that in my Visual Studio Code IDE, there was third party extensions(eslint/jslint/tslint/beautify/jsformatter etc) that were causing a big mess in my JSX code.

I had to go to the extensions and disable all the extension which could hinder in the natural process of linting and code cleaning of React framework.

(These extensions are really great. But disabling them helped me in solving this issue of mine, no offense to anyone.)

If you are facing the same issue and the issue persists event after adding a .jshintrc with content:

{     "esversion": 6 } 

then consider disabling the third party extensions.

Hope my answer helped.



回答2:

I solved this issue by disabling show syntax errors checkbox in visual studio 2015.

Tools -> options - > text editor -> javascript -> intelliSense -> general -> show syntax errors(disable)



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!