I tried subscribeToStateChange but keep getting TypeError: playerRef.subscribeToStateChange is not a function not sure what im doing wrong since I am using functional components.
TypeError: playerRef.subscribeToStateChange is not a function
here is the useEffect hook - trying to subscribe and set state at the same time
React.useEffect(() => { playerRef.subscribeToStateChange(setstate(player?.getState())) });
Does anyone know how to solve this
-----------SOLUTION --------------------
React.useEffect(() => { if (player) { player.subscribeToStateChange(handleBind) } }); function handleBind(state) { setstate(state); }
2.1m questions
2.1m answers
60 comments
57.0k users