I'm getting started with reactjs and tried a simple example in a tutorial.Syntax error occurs when returning html tags.
Here is the error I'm getting
./src/App.js
Syntax error: C:/Users/react-tutotial/src/App.js: Unexpected token (16:6)
14 | render() {
| return{
16 | <div>
| ^
17 | <button>Increment</button>
18 | {this.state.count}
This is the app.js file
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
constructor(){
super();
this.state = {
count : 0
};
}
render() {
return{
<div>
<button>Increment</button>
{this.state.count}
</div>
};
}
}
export default App;
{...}inreturn { ... }denote an object literal. An object literal needs to contain a sequence ofkey: value,pairs, not JSX.