I've been working on implementing the We Are the Champions solo project in React and have gotten everything working properly except for an issue I'm having with localStorage and useEffect. The app is keeping track of endorsements input the user using a firebase realtime database that sets state. The addLike() function is supposed to keep track of which endorsement cards have been liked using an array stored in localStorage rather than the firebase database so that it accurately tracks whether a specific user has liked a card rather than whether the card has been liked by anyone at all. Local storage is (theoretically) being updated each time the localLikeArray is updated using useEffect(), but the problem I'm having is that it seems like useEffect() somehow resets localLikeArray each time it runs. As a subset of this problem, resetLikes() also doesn't work. Can anyone help me understand what's going on?
https://github.com/cwatersaudio/Scrimba-Solo-Projects/tree/main/Endorsements