After following the instructions here, you should have the following:
- Working react app
- Ability to deploy react app to Github Pages
Appcomponent that does initial setup and composes your other componentsNewTodocomponent containing the form for a new TodoTodocomponent containing HTML for a single Todo- CSS files for each component
The next steps are:
- Make sure you rename any
classattributes toclassName - Add props to your
Todocomponent- Will probably need the
idandtextat a minimum. - Render those props instead of having them hardcoded (to test, pass them when you create the component, i.e.
<Todo id="123" text="test" /> - Display the props inside the component, in
Todo.js, i.e.<p>{this.props.text}</p>
- Will probably need the
- Add your AJAX GET call
- Add a
constructor()method to yourAppcomponent and initializethis.statethere with an emptytodosarray.- Make sure to call
super()at the start of your constructor!
- Make sure to call
- Use a
componentDidMount()method in yourAppcomponent and put your AJAX javascript there. - After the AJAX call is complete and successful, update
this.state.todoswith your new Todo items.
- Add a
- Render
Todocomponent for each Todo item.- Use
.mapand the syntax from the slides to loop through your todos and render a new<Todo>for each of them. - Make sure to pass a
keyattribute
- Use
- Add event methods for completing and deleting a ToDo
- Attach them to the buttons using an
onClickprop. - Add your AJAX for completing and deleting inside those methods
- Be sure to add the
bindcall from the slides. - Update
this.stateif necessary
- Attach them to the buttons using an
- Add event method for submitting new Todo form.
- Attach to your form using an
onSubmitprop. - Add your AJAX for adding new Todos inside the event method
- Be sure to add the
bindcall from the slides - Don't forget
event.preventDefault() - Update
statewith your new Todo.
- Attach to your form using an