I have this kind of a setup:
// inside Parent.js class Parent extends React.Component { render() { return { this.props.children } } } // inside Child.js class Child extends React.Component { render() { let message; const greet = this.context.store.parentState.greet; if(greet) message = 'Hello, world!'; return ( <div> { message } </div> ) } } Child.contextTypes = { store: PropTypes.object.isRequired } // inside App.js <Parent> <Route path='/a-path' component={ Child } /> </Parent> When Parent receives new state through setState, its render method is called but the render method in Child is not called!
The reason I want to achieve that is because some logic in Child is dependent on the state of Parent.
If I pass the state of Parent via context like how the store is passed and then access it in Child via this.context.parentState, this seems to be working and causing a call on Child's render method, I guess it's because we're receiving new context.
Why is this? context is great but is there a good way around this particular issue without needing context?