Vijunav Vastivch
Vijunav Vastivch

Reputation: 4211

React.Component Syntax Error on creating div element

Got an issue React.Component:

App.js

import React, { Component } from 'react';

class App extends React.Component {
    render() {
        return(
            <div><h1>Hello World</h1></div>
            );
    }
}
export default App;

When i run the project and check the Inspect Elements the error shows

/App.js Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: D:\Test\reactApp\App.js: Unexpected token (5:9)

 3 |     render() {
  4 |         return(
> 5 |           <div><h1>Hello World</h1></div>
    |           ^
  6 |           );
  7 |     }
  8 | }

My Question is: Is the div elements cannot be done to that particular Component?

I've done searching Here but div elements exists.

What did i missed up?

Upvotes: 2

Views: 1178

Answers (1)

Nikita Malyschkin
Nikita Malyschkin

Reputation: 692

Try to add this to your babel presets: https://babeljs.io/docs/en/babel-preset-react

As an alternativ you could try using parceljs, it comes with all presets preinstalled.

Upvotes: 1

Related Questions