gaearon / gaearon/react-document-title
Blocks context propagation
- Dominant language
- JavaScript
- Stars
- 1.8k
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Description
The behavior is caused by [react-side-effect here](https://github.com/gaearon/react-side-effect/blob/master/src/index.js#L66) (`shouldComponentUpdate` only does a shallow compare on props, see facebook/react#2517), but the upshot is that using `` stops context propagation for a context type declared in its parent but consumed by a descendent.
Totally untested-illustrative-example:
``` javascript
const Parent = 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
}
});
const Child = React.createClass({
contextTypes: {
foo: React.PropTypes.string
},
render() {
// never gets re-rendered with updated `foo` context value
return
}
});
```
I realize that facebook/react#2517 has been discussed to death / is documented clearly in the [React Context documentation](https://facebook.github.io/react/docs/context.html), but I didn't expect to encounter it in react-document-title (I did not find it in the README).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.