@atlaskit/motion
Version:
A set of utilities to apply motion in your application.
15 lines (14 loc) • 383 B
JavaScript
import { useRef } from 'react';
import { useLayoutEffect } from '../utils/use-layout-effect';
/**
* This hook tries to emulate the getSnapshotBeforeUpdate lifecycle method.
*/
export const useSnapshotBeforeUpdate = cb => {
const isFirstRender = useRef(true);
if (!isFirstRender.current) {
cb();
}
useLayoutEffect(() => {
isFirstRender.current = false;
}, []);
};