The worm The worm - 1 year ago 62
React JSX Question

React error even though syntax is correct

I have removed all my code down to the point I just have this:

export class DateApp extends React.Component {
render() {
return (
<div className="dateApp">
<h1> Comments </h1>
export default DateApp;

I get this error on this line:

Module build failed: SyntaxError: Unexpected token

point to the
on the first

I thought it may be a syntax error in one of my functions but as I have removed them all it cant be that.
I have babel, react all installed etc.

Answer Source

If you're using babel to transpile to code:

In the root of your project change the .babelrc file to include the react preset:

  "presets": [

Install the babel react preset using NPM:

npm install --save-dev babel-preset-react