[material-ui][Stack] Not accepting a React Fragment when using it with a divider
Open
@siriwatknp is already working on this.
Since Sep 26, 2023.
component: Stack
scope: system
type: expected behavior
waiting for 👍
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Steps to reproduce 🕹
Link to live example:
Steps:
- Use the Stack component
- Wrap the children elements inside a React Fragment. (in my particular scenario I am sending this as a prop that is why I send it wrapped in a fragment)
- Add a prop to the Stack component to add "dividers" (
divider={<div>xxx</div>}) - The component generates the spacing between each element but it doesn't add the dividers
Sandbox example:
https://codesandbox.io/s/stack-divider-fragment-bug-lnypq9
Current behavior 😯
There is no divider between each children element.
<Stack>
<div>one</div>
// space
<div>two</div>
// space
<div>three</div>
</Stack>
Expected behavior 🤔
Should add between each children element a divider
<Stack>
<div>one</div>
// space
<divider/>
// space
<div>two</div>
// space
<divider/>
// space
<div>three</div>
</Stack>
Context 🔦
I created an extended version of the Stack component. It's almost the same but with some additions. If you send the children elements as a React Fragment is where you get the bug. I need to accept those because it's a valid JSX code and also because my component accepts the children prop.
Your environment 🌎
npx @mui/envinfo
Don't forget to mention which browser you used.
Output from `npx @mui/envinfo` goes here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.