June 7th 2016
Maybe it’s just me, but the first time I built a select box in react, I was a little confused how it would work. When an option is selected, is it an onSelect event? How is the value entered into the state? Here is what I learned.
I was over thinking it. It turns out a select is pretty much handled the same way as any other react input. The
<select> receives an onChange handler that can set the new state with the target value of the selected option. The code should make more sense than my words, so let’s just skip to that.