Skip to content

Conversation

@ohansemmanuel
Copy link
Owner

@ohansemmanuel ohansemmanuel commented Oct 28, 2019

What is this PR about? 🤔

An API change with the Compound components pattern implemented.

Changes 🎁

  • Create a context object to share state with all child components

Before/After 📸

https://advanced-react-patterns-ultrasimplified.netlify.com/compound-components

Other comments 💬

The usage of the component now changes to:

<MediumClap> <MediumClap.Icon /> <MediumClap.Total /> <MediumClap.Count /> </MediumClap>

Improvements may include:

  • Exposing child component props for UI customization

Next PR 👉Compound Component with Callback

MediumClap.Icon = ClapIcon
MediumClap.Count = ClapCount
MediumClap.Total = CountTotal

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MediumClap.Icon = ClapIcon MediumClap.Count = ClapCount MediumClap.Total = CountTotal

This is completely optional. You may export the child components directly - without adding them as publicly accessible properties on the Parent component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants