-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
[RadioButtonGroup] Enable handling of non-RadioButton children #3627
Conversation
...option, | ||
props: { | ||
...option.props, | ||
children: React.Children.map(option.props.children, this.radioButtonMapFunc, this) |
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.
this._radioButtonMapFunc
or rather, rename _radioButtonMapFunc
to radioButtonMapFunc
@bshyong Please could you also update the commit title to match the PR title? (Helps keep the commit history clean). |
Hi guys, thank you for reviewing! I've made the requested changes. |
This does fix the issue for now. But I think this should be contextual to avoid recursive calls on each render. recursion is heavy stuff. But I'm still ok with it as there won't usually be a lot of nested stuff in a radio button group. 👍 @callemall/material-ui Guys take a look please 👍 |
Could you explain? Thanks. |
@mbrookes What I mean is, this implementation recursively walks down the tree to find the RadioButtons which is much more expensive than providing a context with RadioButtonGroup and having it passed down to RadioButton so that they can register themselves as members of that group. |
@alitaheri Thanks. 👍 @bshyong Are you happy to update this PR with that approach? |
Hey guys, I just looked through the code; I'm not sure I understand the context Wonder if I am missing something here or if one of you can provide some Ben Shyong On Sat, May 7, 2016 at 7:04 AM, Matt Brookes notifications@github.com
|
@bshyong Well the idea is, we reverse the flow of control. instead of RadioButtonGroup looking for it's RadioButtons, the RadioButtons register themselves via the hook e.g. |
That sounds like a clever approach. I'll need to find some time to look at Ben Shyong On Sat, May 7, 2016 at 10:43 AM, Ali Taheri Moghaddar <
|
Closing this as there is no movement. |
When nesting children that are not RadioButtons in the RadioButtonGroup, the non-RadioButton elements are ignored.
The following example generates unexpected behavior. All non-RadioButton components are ignored.
Source code:
Rendered output:
Resolves #2225