question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add optional effect to useResizeObserver

See original GitHub issue

We’ve been using useResizeObserver to track when to trigger a side effect, and so end up with code like this:

  const axisRef = useRef();
  const cursorRef = useRef();
  const { width: axisWidth } = useResizeObserver({ ref: axisRef });

  // Reset the axis if the width changes
  useEffect(() => {
    if (cursorRef.current !== null) {
      cursorRef.current.reset();
    }
  }, [axisWidth]);

It would be convenient if we could simply provide this effect to the resize observer.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dannicommented, Jan 5, 2020

Nice!

0reactions
ZeeCodercommented, Dec 29, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

asyarb/use-resize-observer: A small React hook ... - GitHub
Yarn yarn add @asyarb/use-resize-observer # NPM npm i ... Provide an optional callback to perform side effects instead: useResizeObserver({ ref, ...
Read more >
UNPKG - @asyarb/use-resize-observer
The CDN for @asyarb/use-resize-observer. ... 74, // Pass an optional callback to perform side effects instead: 75, useResizeObserver(ref, entry => {.
Read more >
Resize Observer - W3C
Add this to Document . resizeObservers slot. observe(target, options). Adds target to the list of observed elements.
Read more >
@asyarb/use-resize-observer: Docs & Community | Openbase
Hooks - Just pass a ref! Alternative API - Pass an Element and an optional function to handle ResizeObserver callbacks. Typed - Written...
Read more >
wordpress/compose | Block Editor Handbook
ifCondition. Higher-order component creator, creating a new component which renders if the given condition is satisfied or with the given optional prop name....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found