-1

I was following a course on udemy on react components and I was met with this Syntax error.

I have the following dependencies installed using yarn: "dependencies": { "babel-preset-env": "1.5.2", "babel-preset-react": "6.24.1" }

Here's myJSX file:

class Header extends React.Component {
    render() {
        return <p>This is from header</p>;
    }
}

const jsx = (
    <div>
        <h1>Title</h1>
        <Header />
    </div>
);


ReactDOM.render(jsx, document.getElementById('app'));

I am using this command to convert this to the main JS file:

babel src/app.js --out-file=public/scripts/app.js --preset=env,react --watch

Please let me Know what I am doing wrong here

1 Answers1

2

Not 100% that this helps, but as stated in babel docs you should use presets instead of preset

babel script.js --presets react

So your full babel command:

babel src/app.js --out-file public/scripts/app.js --presets env,react --watch
user3210641
  • 1,565
  • 1
  • 10
  • 14