79180746

Date: 2024-11-12 10:43:02
Score: 1.5
Natty:
Report link

Figured out the problem. In my custom hook I added functional dependencies: Set_value and Expired_callback. Expired_callback was causing timer to freeze because it was probably recreated during re-renders and it forced useEffect inside hook to call its return callback first (clears interval) and execute its body with new arguments. Frequent re-renders made it to stun. Removing functional dependency Expired_callback from hooks dependencies array solved the issue. Update: wrapping actual function that will be passed in custom hook as 'Expired_callback' in App component in the useCallback() react hook also solves the problem.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Andrey