index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. var $dJwbH$react = require("react");
  2. function $parcel$export(e, n, v, s) {
  3. Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
  4. }
  5. $parcel$export(module.exports, "composeRefs", () => $9c2aaba23466b352$export$43e446d32b3d21af);
  6. $parcel$export(module.exports, "useComposedRefs", () => $9c2aaba23466b352$export$c7b2cbe3552a0d05);
  7. /**
  8. * Set a given ref to a given value
  9. * This utility takes care of different types of refs: callback refs and RefObject(s)
  10. */ function $9c2aaba23466b352$var$setRef(ref, value) {
  11. if (typeof ref === 'function') ref(value);
  12. else if (ref !== null && ref !== undefined) ref.current = value;
  13. }
  14. /**
  15. * A utility to compose multiple refs together
  16. * Accepts callback refs and RefObject(s)
  17. */ function $9c2aaba23466b352$export$43e446d32b3d21af(...refs) {
  18. return (node)=>refs.forEach((ref)=>$9c2aaba23466b352$var$setRef(ref, node)
  19. )
  20. ;
  21. }
  22. /**
  23. * A custom hook that composes multiple refs
  24. * Accepts callback refs and RefObject(s)
  25. */ function $9c2aaba23466b352$export$c7b2cbe3552a0d05(...refs) {
  26. // eslint-disable-next-line react-hooks/exhaustive-deps
  27. return $dJwbH$react.useCallback($9c2aaba23466b352$export$43e446d32b3d21af(...refs), refs);
  28. }
  29. //# sourceMappingURL=index.js.map