I have a timer component which is the child component of A. I'm having play and pause as state values of the parent and passing it down to the child.
I would like to start a setTimeout for the child component when play is true, the child will get the total duration time from the hook state.
I'm using hooks to store the total Duration in the child and having a setTimeout function inside the useEffect and if the value of play is true and then overwriting the hook state value by decrementing the initial value by 1.
https://stackblitz.com/edit/react-nlxodz has 2 timers, wanted to know if what im doing in ShowTimer is a good approach or not, the cleanup function of the useEffect is called for every State update and the Timer component is not in sync with the ShowTimer even if they both start off with 10 seconds.