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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix useParentSize not updating width and height #1817

Closed
wants to merge 1 commit into from

Conversation

Ti-tanium
Copy link

馃悰 Bug Fix

Fixes: #1816

Description

The parentRef is initially null, so the observer is not registered on the ref element (observer.observe(parentRef.current); not executed) in the initial render. If we don't add parentRef.current to the dependency array, the useEffect won't be executed after parentRef is assigned.

@hshoff
Copy link
Member

hshoff commented May 9, 2024

Hi @Ti-tanium thanks for checking out visx and for the PR but we don't want to add parentRef.current to the useEffect dependency list because mutating the ref doesn't trigger a re-render. See https://epicreact.dev/why-you-shouldnt-put-refs-in-a-dependency-array/ for more info. I'll follow up for more info in the issue.

@hshoff hshoff closed this May 9, 2024
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.

Package Responsive: useParentSize is not updating the width and height
2 participants