reactjsunexpected-tokenparsing-error

Parsing error: Unexpected token ReactJS Problem


I was new in ReactJS and I want to learn the basics from Traversy Media's video tutorial and I apply the code exactly what he have to do. But I got stuck in this part because I got an error Failed to Compile like this: Failed to compile

This is the code I have written:

App.js

import React, { Component } from 'react';
import Todos from './components/Todos';
import './App.css';

class App extends Component {
  state = {
   todos: [
     {
       id: 1,
       title: 'Take out he trash',
       completed: false
     },
     {
       id: 2,
       title: 'Have a Dinner',
       completed: false
     },
     {
       id: 3,
       title: 'Meeting with Boss',
       completed: false
     },
   ]
  };

  render() {
    return (
      <div className="App">
        <Todos todos={this.state.todos} />
      </div>
    );
  }
}

export default App;

Todos.js

import React, {Component} from 'react';
import TodoItem           from './TodoItem';

class Todos extends Component {
  render() {
    return this.props.todos.map((todo) => (
      <TodoItem/>
    ));
  }
}

export default Todos;

TodoItem.js

import React, { Component } from 'react';

export class TodoItem extends Component{
  render(){
    return{
      <div>
        <p>Hello</p>
      </div>
    }
  }
}

export default TodoItem;

Solution

  • It should look like that -

    import React, { Component } from 'react';
    
    export class TodoItem extends Component{
      render(){
        return(
          <div>
            <p>Hello</p>
          </div>
        )
      }
    }
    
    export default TodoItem;