When i use Async/Await i get the warning of : Can’t perform a React state update on an unmounted component

I have already solved this problem, but I don’t know why it works… When I use Async/Await the error persists

const [data, setData]= useState([])
const thisComponent = useRef(true)
useEffect(async()=>{

    const http = axios()
    const {data:{restaurants}}= await http.get('/restaurants')
    if(thisComponent.current){
        setData(restaurants)
    }

    return ()=>{
        thisComponent.current=false
    }
},[])