Skip to content

Instantly share code, notes, and snippets.

@itaditya
Created October 10, 2020 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itaditya/2e74127864341d141bd2339078525bc0 to your computer and use it in GitHub Desktop.
Save itaditya/2e74127864341d141bd2339078525bc0 to your computer and use it in GitHub Desktop.
Implementation of Tab component in compound component pattern.
const Tab = ({ id, children }) => (
<Consumer>
{({ changeTab }) => <div onClick={() => changeTab(id)}>{children}</div>}
</Consumer>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment