Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React JSX error : Unclosed regular expression

Tags:

Recently 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: enter image description here

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

How to solve this?

like image 611
Abhay Shiro Avatar asked Jul 01 '17 13:07

Abhay Shiro


People also ask

Why does React use JSX instead of putting markup and logic in separate files?

Why JSX? React embraces the fact that rendering logic is inherently coupled with other UI logic: how events are handled, how the state changes over time, and how the data is prepared for display.

Which JSX You can write expression inside?

You can put any valid JavaScript expression inside the curly braces in JSX. For example, 2 + 2 , user.firstName , or formatName(user) are all valid JavaScript expressions.

How is JSX valid JavaScript?

What Is JSX? JSX stands for JavaScript syntax extension. It is a JavaScript extension that allows us to describe React's object tree using a syntax that resembles that of an HTML template. It is just an XML-like extension that allows us to write JavaScript that looks like markup and have it returned from a component.

How do you write JavaScript expressions in JSX?

To add JavaScript code inside JSX, we need to write it in curly brackets like this: const App = () => { const number = 10; return ( <div> <p>Number: {number}</p> </div> ); }; Here's a Code Sandbox Demo. Inside the curly brackets we can only write an expression that evaluates to some value.


1 Answers

If you are using jshint plugin, remove it and install ESLint plugin.

It is a good replacement for jshint in reactJS work.

like image 61
Yuvraj Patil Avatar answered Sep 19 '22 17:09

Yuvraj Patil