0

I have two components , each connected via containers, and both having props mapped via the provided state.

There is one action which results in the child component rerendering while its parent does not. I don't understand how this is possible.

I'm certain that my reducer is not mutating the state. The consequence of this action and the rerendering discrepancy is that a prop in the child component is undefined (because it was successfully removed from the state). But that render function would not run if the parent's render function would rerun as I expect it to.

Why doesn't the parent component's render function get called when the state changes?

Micah Alcorn
  • 2,363
  • 2
  • 22
  • 45
  • please post relevant code from your parent component, child component, reducer and the action creator mentioned in the question.. – yadhu Nov 23 '16 at 08:25
  • @free-soul paste it all into the question? I thought that linking was preferable to cluttering here. – Micah Alcorn Nov 23 '16 at 08:26

1 Answers1

1

This sounds like it's related to an implementation detail in react-redux v4 where children components are updated before parent components. This is changing in react-redux v5, which you can test by installing npm install react-redux@next.

Jim Bolla
  • 8,265
  • 36
  • 54
  • Wow, simple enough. I hadn't seen any issues or documentation indicating that. I just assumed that rendering was unidirectional in the same way that state and params are passed. Thank you very much. – Micah Alcorn Nov 23 '16 at 16:59
  • 1
    The next react-redux beta is going to make this change an opt-in behavior for 5.0 because of some React 15 compatibility reasons, so you'll have to enable it to get the "correct" behavior. The plan is to make this the default behavior when React 16 lands. Keep an eye on the react-redux release notes. – Jim Bolla Nov 23 '16 at 17:58