UNPKG

react-atom-toast

Version:
16 lines (13 loc) 407 B
import '../chunk-5USKE2QT.js'; import { useRef } from 'react'; var defaultShouldUpdate = (a, b) => !Object.is(a, b); function usePrevious(state, shouldUpdate = defaultShouldUpdate) { const prevRef = useRef(); const curRef = useRef(); if (shouldUpdate(curRef.current, state)) { prevRef.current = curRef.current; curRef.current = state; } return prevRef.current; } export { usePrevious };