Jammming, literally. addTrack not adding - TypeError: Cannot read properties of undefined (reading 'find')

Hi there,

Tearing my hair out here. Please can someone help with the error I am getting?

I think it has something to do with the fact that my state ‘playlist’ is an empty array to start with so there is nothing to find on the first call but I don’t know how to remedy that because I need the state to be empty to start with.

Link to the project below.

https://github.com/kayholliday/jammmingproto.git

I have been going round in circles for quite some time so any help is hugely, hugely appreciated!!

1 Like

Hey @kayholliday did you ever figure this out? I’m having a similar issue where my Track component crashes the page bc of a state being undefined and the internet seems to think it’s an issue with the asynchronous nature of state setters.