Course lesson

Handle Form Submission States with RTK Query's isLoading and isSuccess Values

In this lesson we learn about the isSuccess state that accompanies a successful mutation. We also use the isLoading state from a mutation hook to prevent a user from filling out a form multiple times.

Duration
1 min
Access
Free
Transcript
Retained from source evidence

In this lesson we learn about the isSuccess state that accompanies a successful mutation. We also use the isLoading state from a mutation hook to prevent a user from filling out a form multiple times.

Initially, we display a sent message powered with useState and a setTimeout that gets removed after 2s. In this lesson we display the message after our query's isSuccess value returns true. We also rely on the combination of isLoading || isSuccess to prevent additional form submissions.