Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use shouldRenderComponent to reduce rendering and recalculation #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

naw
Copy link

@naw naw commented Nov 6, 2015

By creating a component that only takes relevant properties that would
cause a recalculation, we're free to redefine shouldRenderComponent to
compare object equality of all of the props. If any props change, render
(and recalculate); otherwise, no need to render or recalculate. This
is similar to memoization, but using react lifecycle.

In order for this approach to work, you have to create a component that
doesn't take an unrelated prop (i.e. currentTheme).

By creating a component that only takes relevant properties that would
cause a recalculation, we're free to redefine shouldRenderComponent to
compare object equality of all of the props. If any props change, render
(and recalculate); otherwise, no need to render or recalculate.  This
is similar to memoization, but using `react` lifecycle.

In order for this approach to work, you have to create a component that
_doesn't_ take an unrelated prop (i.e. `currentTheme`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants