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

React.cloneElement doesn't preserve context while deprecated React.addons.cloneWithProps does #4008

Closed
rpominov opened this issue Jun 2, 2015 · 2 comments

Comments

@rpominov
Copy link
Contributor

rpominov commented Jun 2, 2015

Is this intentional, and what is the right way of cloning elements with context passed to them correctly?

Thanks!

@jimfb
Copy link
Contributor

jimfb commented Jun 5, 2015

I'm not sure if it was intentional, but either way, we aren't going to change this behavior in a point release because it would break things for more people than it would fix. Sounds like the workaround is to use cloneWIthProps instead, which apparently does preserve context.

Starting with React 0.14, context is parent based anyway, so context will no longer be attached to the element and therefore not impacted by cloneElement / cloneWithProps.

@jimfb jimfb closed this as completed Jun 5, 2015
@rpominov
Copy link
Contributor Author

rpominov commented Jun 5, 2015

I see, so before 0.14 we can use cloneWIthProps and after 0.14 cloneElement will just work — sounds good for me. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants