There's a faster version of egghead. Click here to try it.
1×
Become a member
to unlock all features
Autoplay

    Support a state change handler for all control props

    reactReact
    ^16.3.2

    In our simple situation, having an onToggleChange handler is sufficient because the on state is the only state we have, but in a more complex component, there could be many items of state. We could make an prop callback for each of those items of state, but that could drastically increase the complexity and repetition of our component. Instead, let's make an onStateChange that's called when any state changes.