Skip to content

Instantly share code, notes, and snippets.

@truthseekers
Created May 6, 2018 00:04
Show Gist options
  • Save truthseekers/795ffb4c08b3be11e510830484e0a270 to your computer and use it in GitHub Desktop.
Save truthseekers/795ffb4c08b3be11e510830484e0a270 to your computer and use it in GitHub Desktop.
react todo list 3
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