-
-
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
[Menu] add checks to prevent error for null child #2429
Conversation
I'm not sure. Should we also filter before mapping at this line, to make the count equal to number of non-null children? @oliviertassinari What do you think? |
Yeap, I think that it's a good idea to create a filtered children array. |
@oliviertassinari Please take another look. |
let menuItemCount = 0; | ||
React.Children.forEach(this.props.children, (child) => { | ||
for (let child of filteredChildren) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for ... of ...
is not supported by IE (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of)
Shouldn't we use forEach
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
babel transforms this. see the emitted code
but I can change it if you want. I just thought it's more expressive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, I didn't check, but I remember this issue #1972.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my output I see the transformation, but let's not take any chances. Alright I'll Fix this. Thanks for the tip 👍 👍
@oliviertassinari This is ready. if it's Ok I'll rebase and merge. 😬 |
@subjectix Yes, could you squash down? |
25ddd3b
to
8d5ce9f
Compare
[Menu] add checks to prevent error for null child
mui#2429 allowed for null children in Menu, however, DropDownMenu threw an exception at Line 272 when child was null when doing a check for a matching value to display.
Closes #2067.