import React from 'react'; import Li from './Li.js'; import 'bootstrap/dist/css/bootstrap.css'; class TodoList extends React.Component { constructor(props){ super(props) this.state = { todoList : [ {todo: 'Clean the bathroom' , at:'2020'}, {todo: 'Buy Milk', at:'2019'}, {todo: 'Walk the dog' , at:'2018'}, ] } } addToList = () => { let todo = document.getElementById('user_input').value; if (todo !== '') { let tmp_state = this.state.todoList; tmp_state.push({todo:todo, at:'This year'}) this.setState({tmp_state}) } } render(){ return (

Awesome Todo list

    { this.state.todoList.map( (element, index) => (
  • )) }
) } } export default TodoList