-
Notifications
You must be signed in to change notification settings - Fork 2k
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-context-by-parent warning #204
Comments
It means that, in React 0.14, your drop targets won't receive the context inside modal windows. You can fix this by moving Until React 0.14 is out, you can ignore these warnings. |
We'll see how “portals” context works in 0.14. I don't know yet.. Maybe @jimfb can clarify. |
|
@jimfb Thanks a lot for the explanation! |
related to facebook/react#4081 |
@jimfb is |
@qimingweng no it is in 0.14.0-beta1 It seems as the API may change, you can access it like that: var renderSubtreeIntoContainer = require("react-dom").unstable_renderSubtreeIntoContainer; |
Thanks @slorber (with there was a way to like a comment or something on github, lol) |
@slorber, I've been coming up against this as well. It should be explicitly noted for anyone who finds this discussion that even if you You can certainly require it. But it won't work unless you are on 0.14 beta. However, I have a workaround gist that provides a solution for 0.13 users who would rather not use |
@epferrari the Obviously you should not use that package with a version lower than 0.14 :) |
yes, got it thanks :) As for the mitigating the warnings about owner context vs. parent context in 0.13, what's working well for me at the moment is passing context on a wrapper to nested components on the other side of the portal. Hopefully someone can benefit from that without trying to rewrite |
yes @epferrari the wrapper to forward context works but people probably need the parent to pass context to the portal, instead of writing hardcoded context values. I've implemented something similar here: https://github.com/stample/atom-react/blob/master/src/atomReactContext.js#L326 function ChildContextProviderFactory(context) {
// TODO we are very permissive on the childContextTypes (is it a good idea?)
var childContextTypes = {};
_.keys(context).forEach(function(contextKey) {
childContextTypes[contextKey] = React.PropTypes.any.isRequired
});
return React.createFactory(React.createClass({
displayName: "ChildContextProvider",
childContextTypes: childContextTypes,
propTypes: {
componentProvider: React.PropTypes.func.isRequired,
context: React.PropTypes.object.isRequired
},
getChildContext: function() {
return this.props.context;
},
render: function() {
// TODO simplify this "componentProvider hack" after React 0.14? See https://github.com/facebook/react/issues/3392
var children = this.props.componentProvider();
return children;
}
}));
} |
I've been running into the following React warning when using react-dnd:
It happens anytime I render my
DropTarget()
component outside of the main React.Router, like in the case of a modal/dialog.For modals, I create a new DOM node inside
document.body
and then callReact.render(React.createElement(MyModalDialog));
and then I have draggable elements inside the dialog.Can you help me understand what causes this warning and how I can make it go away?
The text was updated successfully, but these errors were encountered: