Created
December 16, 2020 05:08
-
-
Save CryceTruly/b8260e6a9c4e9eaa04c69040199ec302 to your computer and use it in GitHub Desktop.
Implementing componentDidUpdate using hooks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initialItemsRef = useRef([]); | |
useEffect(() => { | |
if (userItems.length) { | |
const prev = initialItemsRef.current; | |
initialWalletsRef.current = <whatToCheckForChanges>; | |
const newones = initialItemsRef.current; | |
if (newones.length - prev.length === 1) { | |
const difference = newones.find((x) => !prev.map((i) => i.AccountNumber).includes(x.AccountNumber)); | |
// dome stuff here | |
} | |
} | |
}, [whatToCheckForChanges.length]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment