index.js 877 B

123456789101112131415161718192021222324252627282930
  1. var $kjM8v$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, "usePrevious", () => $11bc82d0001dc9a8$export$5cae361ad82dce8b);
  6. function $11bc82d0001dc9a8$export$5cae361ad82dce8b(value) {
  7. const ref = $kjM8v$react.useRef({
  8. value: value,
  9. previous: value
  10. }); // We compare values before making an update to ensure that
  11. // a change has been made. This ensures the previous value is
  12. // persisted correctly between renders.
  13. return $kjM8v$react.useMemo(()=>{
  14. if (ref.current.value !== value) {
  15. ref.current.previous = ref.current.value;
  16. ref.current.value = value;
  17. }
  18. return ref.current.previous;
  19. }, [
  20. value
  21. ]);
  22. }
  23. //# sourceMappingURL=index.js.map