Changes storeState === prevStoreState || areInputsEqual(...) to storeState === prevStoreState && areInputsEqual(...) when considering whether or not to return the cached value of a computed prop. Only if both conditions are true should we blindly return the cached value. If either condition is false, we should re-calculate and find out if the value has changed. If it has not, return the cached value still (this may happen if inputs are equal and store state has changed that the computed prop does not depend on). Otherwise update cached value and trigger re-render.
I believe this is related to the changes introduced in #764. This PR optimized computed props to reduce/remove the number of unwanted re-renders, however the optimization was maybe a bit too aggressive and missed a few edge cases where it doesn't trigger a re-render when it should.
The new test fails prior to this code change and illustrates the issue that prompted the filing of #873.
This PR also removes an un-used argument from the createComputedPropertyBinder and changes the runOnce variable name to hasRunOnce (just for a little more clarity - this always confused be a bit at first).
storeState === prevStoreState || areInputsEqual(...)
tostoreState === prevStoreState && areInputsEqual(...)
when considering whether or not to return the cached value of a computed prop. Only if both conditions are true should we blindly return the cached value. If either condition is false, we should re-calculate and find out if the value has changed. If it has not, return the cached value still (this may happen if inputs are equal and store state has changed that the computed prop does not depend on). Otherwise update cached value and trigger re-render.createComputedPropertyBinder
and changes therunOnce
variable name tohasRunOnce
(just for a little more clarity - this always confused be a bit at first).fixes #873