ZeeCoder / use-resize-observer

A React hook that allows you to use a ResizeObserver to measure an element's size.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Offering throttled- and debounced variants

ZeeCoder opened this issue · comments

Instead of having them as options, I think it would be better to ship composing hooks, basically as they are outlined in the readme already:

This would allow me to keep the base interface minimalistic, while at the same time offer solutions to a seemingly frequent use case.

This is how it would look I think:

import useResizeObserver from 'use-resize-observer/throttled';
import useResizeObserver from 'use-resize-observer/debounced';

// Where the API / options are the exact same.

The only downside that I would probably have to provide polyfilled builds as well, so maybe:

import useResizeObserver from 'use-resize-observer/throttled/polyfilled';
import useResizeObserver from 'use-resize-observer/debounced/polyfilled';

And of course I would have to run the whole test suite and more on these builds.

I'll just leave this issue here to assess demand.