Skip to content
This repository has been archived by the owner on Aug 27, 2018. It is now read-only.

Fix shouldComponentUpdate check #34

Merged
merged 1 commit into from
Mar 27, 2017
Merged

Conversation

myitcv
Copy link
Owner

@myitcv myitcv commented Mar 27, 2017

There was a bug whereby a component where the props haven't changed would always re-render regardless of the state having changed or not.

There already exists a check that only calls the underlying setState if the state has genuinely changed, but this failed to cover the situation where the component itself is re-rendered by its parent component and its props have not changed). In this case, shouldComponentUpdate is still called. Where a component had only state and no props, we were unconditionally returning true. So we need in effect a double safety net to check the state again (no real cost here)

@myitcv myitcv merged commit c6a4a02 into master Mar 27, 2017
@myitcv myitcv deleted the fix_shouldComponentUpdate_check branch March 27, 2017 14:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant