So I needed to transfer the routing context (I’m using react-router) from component X
to component ContactsEditDialog
, as it’s rendered in some remote area of the DOM tree (#modal
), not under the node corresponding to component X
, as usual...
So I basically replaced this...
React.withContext({ router: this.context.router }, () => {
React.render(
<ContactsEditDialog { ...this.props } { ...i18nData }/>,
document.getElementById('modal')
);
});
...with this...
var router = this.context.router;
var ContactsEditDialogWrapper = React.createClass({
childContextTypes: {
router: React.PropTypes.func.isRequired
},
getChildContext() {
return { router: router };
},
render() {
return <ContactsEditDialog { ...this.props } { ...i18nData }/>;
}
});
React.render(
<ContactsEditDialogWrapper { ...this.props }/>,
document.getElementById('modal')
);
...all because React.withContext()
is marked as deprecated...