Update the sections to allow edit (change instructor) and delete
Section
component that takes the section object (section id and instructor id) and the list of all instructorskey
attribute on each Section
in the Course
Section
to show a dropbox and delete button, using the HTML/bootstrap in mockups/mockup03.html
sections
state) it should be controlled
We could create a state variable in Section
for the section instructor id and update it there, just like we pushed the
list of section instructors down into Course
.
To show the alternative, we'll do the opposite strategy here: leave the list of sections state at the Course
level and update
it there.
onChange
handler for the dropbox into Section
from Course
Course
Finish the app so that you can add new courses. This will required a state variable at the App
level to hold the
list of courses and be able to change it. You always have choices about where and how to store your state throughout the app.
For this exercise, keep the sections state at the Course
level.
Your app should look like the image below. mockups/mockup04.html
has the html/css you need.
The textbox to add a new course can be uncontrolled or controlled. In the former case, the user can type freely. We only care about the value in the textbox when they click the button, and that can be retrieved (and cleared) in the handler. Making it controlled means you need a state variable and update handler to back it, and your handler can just use that state variable. Either way works in this case.
hint: using a form submit instead of just a button makes either click or enter work, which is better UX. just remember to prevent the default form handler from reloading the page.