Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3 Compound Components #17

Open
wants to merge 3 commits into
base: 02
Choose a base branch
from
Open

#3 Compound Components #17

wants to merge 3 commits into from

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant