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 have 3 instances of same component (very similar to the VisibleTodoList example) where this component has a selector that relies on the given "prop" value to get the state. The only difference is each instance resides under different parent components.
Based on the VisibleTodoList example, I created makeMapStateToProps that looks like this:-
... initialProps has same value as ownProps, but fails on === check.
My question is... why, in my scenario, do I have to use the "prop" provided from makeMapStateToProps() instead of using the approach from VisibleTodoList example to prevent all instances of same component from rerendering?
I have 3 instances of same component (very similar to the
VisibleTodoList
example) where this component has a selector that relies on the given "prop" value to get the state. The only difference is each instance resides under different parent components.Based on the
VisibleTodoList
example, I createdmakeMapStateToProps
that looks like this:-While it works, all 3 instances'
render()
get triggered even though only one instance should get rerendered on state change.After poking around, I found out that
makeMapStateToProps()
also provides "prop". So, out of curiosity, I made the following tweak to the above code:-Now, it functions exactly what I expected and only one instance gets rerendered instead of all 3.
When I printed out
initialProps
andownProps
and perform===
check......
initialProps
has same value asownProps
, but fails on===
check.My question is... why, in my scenario, do I have to use the "prop" provided from
makeMapStateToProps()
instead of using the approach fromVisibleTodoList
example to prevent all instances of same component from rerendering?I'm using the following versions:-
"react": "15.3.1"
"react-redux": "4.4.5"
"reselect": "2.5.3"
Thank you.
The text was updated successfully, but these errors were encountered: