DEV Community

Discussion on: React's useEffect & useState hooks

Collapse
 
polar profile image
Polar Humenn • Edited

Hi Christine. I believe you have an anomaly in your clean up example. The type of the return of your unsubscribePlayers(players) call is not specified, so the return may be misleading, as a call to unsubscribe the players immediately before returning. For the clean up to work properly, you must return a function that will be called when needed. Perhaps you meant the following:

return  (() => unsubscribePlayers(players));
Enter fullscreen mode Exit fullscreen mode

However, I could be wrong, since the function call unsubscribePlayers may indeed return a function.

Anyway, nice post! Keep it up, very entertaining.

Collapse
 
enitschorn profile image
Christine Schorn (she/her)

Hey Polar, good catch, thank you. I've updated it :)