Conditional Fetching

Conditional Fetching

Overview

Query hooks automatically begin fetching data as soon as the component is mounted. But, there are use cases where you may want to delay fetching data until some condition becomes true. RTK Query supports conditional fetching to enable that behavior.

If you want to prevent a query from automatically running, you can use the skip parameter in a hook.

examples

remarks

:::tip Typescript users may wish to use skipToken as an alternative to the skip option in order to skip running a query, while still keeping types for the endpoint accurate. :::

Conditional Fetching Example

Last updated