DEV Community

Agik Setiawan
Agik Setiawan

Posted on

5 4

Use Side Effect with RTK Query Redux Tookit

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()
Enter fullscreen mode Exit fullscreen mode

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])
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay