[docs] Add note in docs about componentsProps.root taking precedence#33097
Merged
ZeeshanTamboli merged 7 commits intomui:masterfrom Jun 24, 2022
Merged
Conversation
componentsProps.root taking precedence
Member
|
cc @michaldudak can you verify and approve? |
michaldudak
reviewed
Jun 23, 2022
Member
michaldudak
left a comment
There was a problem hiding this comment.
However, I think that it should be the other way around, the additional native props passed directly on the component should take precedence.
IMO what's set explicitly should override values set implicitly. If you set componentsProps.root.id = 'x', you clearly state that the id prop of the root slot should be 'x'. On the other hand, spreading additional unstyled component's props on the root is more of a convention. That's why I think the current way is more intuitive.
Co-authored-by: Michał Dudak <michal.dudak@gmail.com>
…s://github.com/ZeeshanTamboli/material-ui into base-componentsProps-root-slot-precedence-docs
Member
Author
|
I am merging this. The docs suggestion is applied. Could be helpful in #33272. |
daniel-rabe
pushed a commit
to daniel-rabe/material-ui
that referenced
this pull request
Nov 29, 2022
mui#33097) * docs * docs wording * run CI * Update docs/data/base/getting-started/usage/usage.md Co-authored-by: Michał Dudak <michal.dudak@gmail.com> Co-authored-by: Michał Dudak <michal.dudak@gmail.com>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While working on
SnackbarUnstyledcomponent, I stumbled upon a use case about what if both props are specified which one will take precedence?componentsProps.rootor the additional native DOM props?This is what I mean - see the following CodeSandbox: https://codesandbox.io/s/eloquent-hugle-xfri7g?file=/src/Demo.tsx:1245-1449
Here the id
badge-1ofrootslot gets applied, notbadge-2. Hence mentioned it in the docs.However, I think that it should be the other way around, the additional native props passed directly on the component should take precedence. But then we will have to change the implementation on all the components.
Docs preview: https://deploy-preview-33097--material-ui.netlify.app/base/getting-started/usage/