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

Create an egghead account to access 5000+ tutorials and resources from expert developers.

Create account
Autoplay

    Advanced React Component Patterns Update

    This lesson was part of the Advanced React Component Patterns course, which has been updated to reflect the new patterns and API available in React 16.3+.

    Write Compound Components

    reactReact

    Compound component gives more rendering control to the user. The functionality of the component stays intact while how it looks and the order of the children can be changed at will. We get this functionality by using the special React.Children.map function to map over the children given to our <Toggle/> component. We map over the children to pass the on state as a prop to its children. We move the visual pieces of the component out into function components and add them as static properties to <Toggle/>.