BugdrLog in
All problems
MediumJavaScriptFrontend Engineer · dom · hooks · react · resize-observer · responsive

useParentSize dimension tracking

★ 0.0 (0 ratings)60 min0 engineers solved this

Your assignment

visx is a collection of low-level React visualization packages. The @visx/responsive package provides helpers for making charts fill their container. useParentSize is a hook that attaches a ResizeObserver to a DOM element and exposes its measured dimensions as state; resize notifications are debounced and applied through requestAnimationFrame. ParentSize is a component built on the hook that passes the measured dimensions to a render-prop child, and withParentSize is an HOC version of the same behaviour. Callers attach the returned ref to a div and read width and height to size SVG charts.

What the team is seeing

incident log
On our analytics dashboard, some charts that appear after the page has loaded stay squashed to nothing and never grow to fill their box. Reloading the page sometimes fixes it, but the charts still do not respond when the browser window is resized.

Acceptance checks 1

  • Check 1

Discussion is locked — log in and complete this problem to join the discussion and rate your experience.