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 propsOrStateMapsEqual in memo so that tearoffs don't cause unnecessary rerenders #643

Merged
merged 2 commits into from
Nov 17, 2020

Conversation

aaronlademann-wf
Copy link
Contributor

Motivation

Tearoffs aren't guaranteed to be identical, and we don't want the use of them to trigger unnecessary rerenders in memoized function components.

Closely related to how we handled this same problem for connected components

Changes

  1. Use propsOrStateMapsEqual for areEqual instead of default JS equality when the consumer does not specify their own custom handler for the areEqual parameter.
  2. Note that we're using our own utility to do the default shallow comparison in the doc comment for memo.
  3. Add a regression test.

+ So that Dart tear-off functions passed as prop values do not cause unexpected re-render(s) when a function component is wrapped with `memo`.
@aviary2-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+10

@Workiva/release-management-p

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from RM

@rmconsole6-wk rmconsole6-wk merged commit f3cac7a into master Nov 17, 2020
@rmconsole6-wk rmconsole6-wk deleted the fix-memo-default-prop-comparison branch November 17, 2020 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants