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

Fix useScrollIntoView ignoring parameter changes #2866

Merged
merged 3 commits into from Nov 6, 2022

Conversation

rChaoz
Copy link
Contributor

@rChaoz rChaoz commented Nov 2, 2022

Currently, useScrollIntoView returns a memoized callback that always refers to the params passed during the first render of the calling component, so calling with dynamically computed params, e.g. useScrollIntoView({ offset: someVariable }) will memoize the offset passed during the first render. If the component re-renders, any new offset passed is ignored.

Aditionally, 'scrollableRef.current' is an invalid dependency, see https://epicreact.dev/why-you-shouldnt-put-refs-in-a-dependency-array/

Currently, useScrollIntoView returns a memoized callback that always
refers to the params passed during the first render of the calling
component, so calling with dynamically computed params, e.g.
useScrollIntoView({ offset: someVariable }) will memoize the offset
passed during the first render. If the component re-renders, any new
offset passed is ignored.

Aditionally, 'scrollableRef.current' is an invalid dependency, see
https://epicreact.dev/why-you-shouldnt-put-refs-in-a-dependency-array/
@rtivital rtivital merged commit f83c6a0 into mantinedev:master Nov 6, 2022
@rtivital
Copy link
Member

rtivital commented Nov 6, 2022

Thanks!

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.

None yet

2 participants