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

Memoize input and meta #640

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

asazernik
Copy link
Contributor

Preventing unnecessary re-renders is the name of the game. Users will only see gains if they pass in a pure/memoized component, but if they do it's a big difference.

The rule against nesting of hook calls requires us to change the
structure of this code somewhat.
If the child components of <Field> check for reference equality of their
props to decide to re-render, the old code was causing excessive
re-renders by changing the identity of input and meta props.
@codecov
Copy link

codecov bot commented Oct 1, 2019

Codecov Report

Merging #640 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #640   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          17     17           
  Lines         251    257    +6     
  Branches       58     57    -1     
=====================================
+ Hits          251    257    +6
Impacted Files Coverage Δ
src/useField.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 692f1d1...40060ae. Read the comment docs.

@asazernik
Copy link
Contributor Author

asazernik commented Oct 21, 2019

Note on second glance - because of extensive whitespace changes, the diffs are best viewed with --color-words --ignore-space-change

@erikras
Copy link
Member

erikras commented Oct 28, 2019

Can you show me a render counting test that passes if meta and input are memoized but fails if they are not?

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