Skip to content
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

Refactor cloneElement to context in RadioGroup #5443

Closed
yesmeck opened this issue Mar 23, 2017 · 4 comments
Closed

Refactor cloneElement to context in RadioGroup #5443

yesmeck opened this issue Mar 23, 2017 · 4 comments
Assignees

Comments

@yesmeck
Copy link
Member

yesmeck commented Mar 23, 2017

Currently, we use cloneElement to pass props to Radio in RadioGroup. This approach leads to Radio cannot be wrapped by other components or created from HOC.

For example, following code won't work:

<RadioGroup onChange={this.onChange} value={this.state.value}>
  <div>
    <img src="A.png" />
    <Radio value={1}>A</Radio>
  </div>  
  <div>
    <img src="B.png" />
    <Radio value={2}>B</Radio>
  </div>  
</RadioGroup>

By replacing cloneElement with context, Radio can be free to compose.

Related issue: #5165

@afc163
Copy link
Member

afc163 commented Mar 23, 2017

Menu and MenuItem has same issue.

@yesmeck
Copy link
Member Author

yesmeck commented Mar 23, 2017

react-component/menu#72

I've tried on Menu, got some blocks...

@afc163
Copy link
Member

afc163 commented Mar 23, 2017

Yep... RadioGroup don't have this problem.

@yesmeck yesmeck self-assigned this Mar 23, 2017
@yesmeck yesmeck changed the title Use context instead of cloneElement in RadioGroup Refactor cloneElement to context in RadioGroup Mar 23, 2017
@lock
Copy link

lock bot commented May 1, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants