I am using usePreviousValue custom hook to get previous props value from my component:
usePreviousValue
const usePreviousValue = value => { const ref = useRef();