DEV Community

Damian Diego
Damian Diego

Posted on

setState is not executed even though it is called

For some reason, the setStates in this function are not working and the execution goes directly to the getPodcastDetails function!
Image description

Top comments (1)

Collapse
 
brense profile image
Rense Bakker

Why is the getData function nested inside a callback? Just make the callback itself async and move the logic inside getData function up to the callback itself. You also don't need the setSelectedPodcast and setSelectedPodcastLoadState as dependencies for the callback, they are readonly values and cannot change. Not sure if that will fix your problem, but it's worth a shot.