DEV Community

Discussion on: Angular Concepts in React: The Async Pipe

Collapse
 
lysofdev profile image
Esteban Hernández

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.