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
The behavior is caused by react-side-effect here (shouldComponentUpdate only does a shallow compare on props, see facebook/react#2517), but the upshot is that using <DocumentTitle/> stops context propagation for a context type declared in its parent but consumed by a descendent.
Totally untested-illustrative-example:
constParent=React.createClass({childContextTypes: {foo: React.PropTypes.any},getChildContext(){return{foo: this.state.foo};},getInitialState(){return{foo: null};},componentDidMount(){setTimeout(()=>this.setState({foo: 'bar'});},render(){return<DocumentTitletitle="sup"><Child/></DocumentTitle/>}});constChild=React.createClass({contextTypes: {foo: React.PropTypes.string},render(){// never gets re-rendered with updated `foo` context valuereturn<div>{this.context.foo}</div>;}});
I realize that facebook/react#2517 has been discussed to death / is documented clearly in the React Context documentation, but I didn't expect to encounter it in react-document-title (I did not find it in the README).
The text was updated successfully, but these errors were encountered:
On the off-chance anyone discovers this, my solution was to call forceUpdate directly on the <DocumentTitle/> component from Parent in situations where I knew <DocumentTitle/> would not re-render (context changes).
The behavior is caused by react-side-effect here (
shouldComponentUpdate
only does a shallow compare on props, see facebook/react#2517), but the upshot is that using<DocumentTitle/>
stops context propagation for a context type declared in its parent but consumed by a descendent.Totally untested-illustrative-example:
I realize that facebook/react#2517 has been discussed to death / is documented clearly in the React Context documentation, but I didn't expect to encounter it in react-document-title (I did not find it in the README).
The text was updated successfully, but these errors were encountered: