re: Angular Concepts in React: The Async Pipe VIEW POST


Why does the return function unsubscribe?


The useEffect hook can optionally return a 'clean-up' function which will be called once the input, in this case the 'ticker' observable changes or if the component unmounts. So, if our Observable where to change then we'd unsubscribe from the first one before subscribing to the new one.

code of conduct - report abuse