react-viewport-utils icon indicating copy to clipboard operation
react-viewport-utils copied to clipboard

helper to adjust priority

Open garthenweb opened this issue 6 years ago • 0 comments

In a lot of cases, the priority of an update is based on whether an element is in the viewport or not. With a simple helper function, we can make it more convenient to define it properly.

const MyComponent = () => {
  const element = useRef(null);
  const scroll = useScroll({
    priority: createViewportPriorityUpdater(element),
  });
  return <div ref={ref} />;
};

garthenweb avatar Aug 20 '19 20:08 garthenweb