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

    Make Compound React Components Flexible

    reactReact
    ^16.3.2

    Our current compound component implementation is great, but it's limited in that users cannot render the structure they need. Let's allow the user to have more flexibility by using React context to share the implicit state to our child <Toggle/> components. We will walk through using React's official context API with React.createContext and use the given Provider and Consumer components to share state implicitly between our compound components giving our users the flexibility they need out of our component.