-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Stack shows dividers between null children #43969
Comments
const childrenArray = React.Children.toArray(children).filter(Boolean); A component that return |
closing the issue based on #43969 (comment) |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @githorse How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
@sai6855 should this be closed? I get that this is the current behavior, but isn't that strictly less useful than filtering out the Seems like that line might be better written as something like:
(Untested; suggestion from this SO issue). But I may be missing something -- maybe somebody has a good use case for the current behavior. |
Steps to reproduce
Stackblitz example
Current behavior
When a child element returns
null
(conditionally), theStack
still treats this as a child and inserts a divider, even though there is no DOM element to divide:Expected behavior
I would have expected that null children would not be treated as DOM elements and not produce any dividers.
Context
I have an action/navigation bar with several sections. Under some conditions, some of those sections don't make any sense, and so the components that render them return
null
in that case. I don't want the dividers to show up around invisible sections.Your environment
npx @mui/envinfo
Search keywords: stack divider child children null
The text was updated successfully, but these errors were encountered: