well i have been using this method to avoid memory leak on unmounted components with async calls:
const isMounted = useRef() const [data,setData]=useState()