Passed function is executed as "onUnmount" lifecycle function.
It's, only when the component is unmounted.
This also works because a useEffect without dependencies is used whereas return functions of useEffects having dependencies are are called on dependency changes too.
Passed function is executed as "onUnmount" lifecycle function. It's, only when the component is unmounted. This also works because a useEffect without dependencies is used whereas return functions of useEffects having dependencies are are called on dependency changes too.