Created
May 6, 2018 00:04
-
-
Save truthseekers/795ffb4c08b3be11e510830484e0a270 to your computer and use it in GitHub Desktop.
react todo list 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TodoApp extends React.Component{ | |
constructor(props){ | |
super(props); | |
// Set initial state | |
this.state = { | |
items: ['Buy enchiladas', 'Buy Carrots', 'Buy Celery', 'add a form'] | |
}; | |
}; | |
render(){ | |
return ( | |
<div> | |
<TodoList todos={this.state.items} /> | |
</div> | |
); | |
} | |
} | |
class TodoList extends React.Component{ | |
constructor(props){ | |
super(props); | |
} | |
getListItems(){ | |
return ( | |
this.props.todos.map((item) => { | |
return ( <Todo todo={item} /> ); | |
}) | |
); | |
} | |
// render function for TodoList | |
//render TodoApp instead | |
ReactDOM.render(<div> | |
<App /> | |
<TodoApp /> | |
</div>, document.getElementById('root')); | |
registerServiceWorker(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment