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.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.