UNPKG

@atlaskit/editor-common

Version:

A package that contains common classes and components for editor and renderer

18 lines (17 loc) 507 B
import { useRef } from 'react'; /** * * Can be used to get the previous state of a prop. * This can be helpful when converting class components to functional * where we don't have the `prevProps`. * * @param value New state of the * @param initialValue Optional parameter for the inital state of the component * @returns */ export default function usePreviousState(value, initialValue) { var ref = useRef(initialValue); var prevValue = ref.current; ref.current = value; return prevValue; }