import { useRef } from '../lib/teact/teact'; function usePrevious(next: T): T | undefined; function usePrevious(next: T, shouldSkipUndefined: true): Exclude | undefined; function usePrevious(next: T, shouldSkipUndefined?: boolean): Exclude | undefined; function usePrevious(next: T, shouldSkipUndefined?: boolean) { const ref = useRef(); const { current } = ref; if (!shouldSkipUndefined || next !== undefined) { ref.current = next; } return current; } export default usePrevious;