You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it's a bug because it prevents child context from being dependent on component state.
var React = require('react');
var contextTypes = {
name: React.PropTypes.string
};
class Test extends React.Component {
getInitialState() {
return {name: 'Name'};
}
getChildContext() {
return {name: this.state.name};
}
render() {
return <div />;
}
}
Test.childContextTypes = contextTypes;
console.log(React.renderToString(<Test />));
Results in:
return {name: this.state.name};
^
TypeError: Cannot read property 'name' of null
at Test.getChildContext ([stdin]:19082:29)
at assign._processChildContext ([stdin]:6850:53)
at assign._renderValidatedComponent ([stdin]:7249:33)
at wrapper [as _renderValidatedComponent] ([stdin]:13368:21)
at assign.mountComponent ([stdin]:6558:32)
at wrapper [as mountComponent] ([stdin]:13368:21)
at [stdin]:14177:27
at ReactServerRenderingTransaction.Mixin.perform ([stdin]:16220:20)
at Object.renderToString ([stdin]:14174:24)
at Object.react ([stdin]:19092:19)
The text was updated successfully, but these errors were encountered:
If it references this.props and this.state, does that mean that context change has to propagate aftercomponentDidUpdate, thus forcing reconciliation twice?
I think it's a bug because it prevents child context from being dependent on component state.
Results in:
The text was updated successfully, but these errors were encountered: