UNPKG

@atlaskit/motion

Version:

A set of utilities to apply motion in your application.

15 lines (14 loc) 416 B
import { useRef } from 'react'; import { useLayoutEffect } from '../utils/use-layout-effect'; /** * This hook tries to emulate the getSnapshotBeforeUpdate lifecycle method. */ export var useSnapshotBeforeUpdate = function useSnapshotBeforeUpdate(cb) { var isFirstRender = useRef(true); if (!isFirstRender.current) { cb(); } useLayoutEffect(function () { isFirstRender.current = false; }, []); };