Dynamically Replacing Components Based on User Actions

Detecting elements using plain JavaScript

To detect events in plain JavaScript, we’d add the onchange attribute in line 7 to our select element, setting its value to the JavaScript code we’d like to execute. This is exactly how it works in React as well, except that we use the attribute onChange (note the capitalized “C”):

Get hands-on with 1400+ tech skills courses.