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

measureRef prevents component list item component memoization #591

Open
vinczemarton opened this issue Aug 22, 2023 · 0 comments
Open

measureRef prevents component list item component memoization #591

vinczemarton opened this issue Aug 22, 2023 · 0 comments

Comments

@vinczemarton
Copy link

vinczemarton commented Aug 22, 2023

Bug Report

Describe the Bug

I'm testing the library and with dynamic sizing I cannot get a memoized component to work. What I can see is that measureRef is always a new reference which prevents us from using memo() to its effect.

Maybe moving the measureRef function to the top component level and wrapping it in useCallback can help, but I'm having trouble making a working PR.

How to Reproduce

  1. Start from the Dynamic Size example.
  2. add some logging to keep track of renders
  3. add memoization to the accordion component

You can see that adding memoization does not change how many times a component is rendered. It is rerendered whenever something new is added/removed from the list.

It seems to be the measureRef reference as when I don't provide the measureRef function to the component it seems to work fine.

CodeSandbox Link

Show me the bug on CodeSandbox.

Expected Behavior

Only the newly inserted elements should rerender.

Screenshots

image

Your Environment

  • Device: [MacBook Pro]
  • OS: [macOS]
  • Browser: [Chrome]
  • Version: [latest]
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

No branches or pull requests

1 participant