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

[docs] Add a composition section #6049

Merged
merged 1 commit into from
Feb 1, 2017
Merged

[docs] Add a composition section #6049

merged 1 commit into from
Feb 1, 2017

Conversation

oliviertassinari
Copy link
Member

  • PR has tests / docs demo, and is linted.
  • Commit and PR titles begin with [ComponentName], and are in imperative form: "[Component] Fix leaky abstraction".
  • Description explains the issue / use-case resolved, and auto-closes the related issue(s) (http://tr.im/vFqem).

Closes #6041.

@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label Feb 1, 2017
@stunaz
Copy link
Contributor

stunaz commented Feb 1, 2017

Doesn't appear like a numbered lists

list2

Copy link
Member

@mbrookes mbrookes left a comment

Choose a reason for hiding this comment

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

Looks good. A few grammar tweaks and a question...


In order to provide the maximum flexibility and performance,
we need a way to know the nature of the children elements components
receive as property.
Copy link
Member

Choose a reason for hiding this comment

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

"the child elements a component receives"?

with a `muiName` static property.

However, users like to wrap components in order to enhance them.
That's conflicting with our `muiName` solution.
Copy link
Member

Choose a reason for hiding this comment

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

"to enhance them, which can conflict with our muiName solution.

In order to provide the maximum flexibility and performance,
we need a way to know the nature of the children elements components
receive as property.
To solve that problem we tag some of our components when needed
Copy link
Member

Choose a reason for hiding this comment

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

"this problem"


However, users like to wrap components in order to enhance them.
That's conflicting with our `muiName` solution.
If you encounter that issue, you need to:
Copy link
Member

Choose a reason for hiding this comment

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

"this issue"

That's conflicting with our `muiName` solution.
If you encounter that issue, you need to:
1. Forward the properties.
2. Use the same tag for your wrapping component that used with the wrapped component.
Copy link
Member

Choose a reason for hiding this comment

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

"that is used"


## API consistency

You may have noticed some inconsistency in our API regarding composting components.
Copy link
Member

Choose a reason for hiding this comment

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

composting components

😆 We have a few of those on master!

To provide some transparency, we have been using the following rules when designing the API:

1. Using the `children` property is the idiomatic way to do composition with React.
2. When we need limited children composition, providing explicit property is making the implementation simpler and more performant. For instance, the `<Tab />` takes an `icon` and a `label` property.
Copy link
Member

Choose a reason for hiding this comment

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

When we need limited children composition

"limited child composition" perhaps? But what does that mean?

@mbrookes
Copy link
Member

mbrookes commented Feb 1, 2017

composting components

You missed one!

@oliviertassinari
Copy link
Member Author

Oups 🍂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrap MenuItem as a higher order component
4 participants