use-motion-value-event.mjs 485 B

12345678910111213
  1. import { useInsertionEffect } from 'react';
  2. function useMotionValueEvent(value, event, callback) {
  3. /**
  4. * useInsertionEffect will create subscriptions before any other
  5. * effects will run. Effects run upwards through the tree so it
  6. * can be that binding a useLayoutEffect higher up the tree can
  7. * miss changes from lower down the tree.
  8. */
  9. useInsertionEffect(() => value.on(event, callback), [value, event, callback]);
  10. }
  11. export { useMotionValueEvent };