From the course: React for Web Designers

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Solution

Solution

(upbeat music) - [Instructor] Here's my solution to the color selector challenge. The goal is to activate the color selector so that it causes changes in the available list of sizes and optionally, to update the selected size piece of state based on that availability check. So if I change the color from red to green, I can see that the shoe changes color. And my list of sizes is shrinking. Now if I start changing things over here, I'm starting to paint myself into a corner a little bit where some of the colors are disappearing, and some of the sizes are disappearing as well. We could add a react powered reset button to fix all this. We don't have it right now, so I'll just reload. I also said to watch out for weird behavior, and of course, paint ourselves into a corner like that was one piece of weird behavior, but here's another one. If I keep the color red and go to size 12, say, the picture shows a brown shoe but the currently selected color is green. We're going to look at why…

Contents