Closed opr1cob closed 3 years ago
Interesting.
Can you also post the code for debounce
and delay
?
Or better yet, could you create a codesandbox, reproducing the issue?
For the time being, you can also try and use this solution for a debounced hook instead: https://codesandbox.io/s/use-resize-observer-throttle-and-debounce-8uvsg?file=/src/useDebouncedResizeObserver.js
without debounce and delay also resize callback is not triggering in v7.0.1 useResizeDetector({ ref: communicationref, onResize: ({ width, height }) => { console.log(height); }, })
That should work for sure, and I have tests covering it. I really can't look into the issue without having a way to reproduce it.
One thing I'd also try from the top of my head is using the callback ref returned by the hook, instead of passing in an object ref, so:
const { ref } = useResizeDetector({
onResize: ({ width, height }) => {
console.log(height);
},
});
<div ref={ref} />
This would work better if you mount the observed component with a delay for example.
I have tried the suggested way to capture the callback but no luck , its not working in v7.0.1
Sorry I really am unable to help unless you provide me a reproduction of the issue through either a repo, codesandbox or something similar.
I'm closing this for now, but feel free to reopen if you have a reproduction.
useResizeDetector({ ref: communicationref, onResize: debounce(handlecommunicationResize, delay, { maxWait: 1000 }), })
function handlecommunicationResize({ height }) { console.log(height); }
its working perfectly in v7.0.0