How to detect side effect in RTK Query Redux Toolkit?
We can use React Hook sideEffect and put RTQ query into sideEffect for retrieve any changes.
Example call function from RTK Query:
const {data,isSuccess,isLoading,isError} = useGetUserQuery()
and we can detect isSuccess,data,isloading with useEffect Hook
useEffect(()=>{
if(isSuccess==true){
// detect isSuccess
}
if(isLoading==true){
// detect isLoading
}
if(isError==true){
// detect isError
}
},[isSuccess,data,isLoading,isError])
Top comments (0)