useRequest

This Hook is available since v1.4.0.
This Hook is marked asdeprecatedsincev1.5.0.

A hook that helps you manage the request status, including loading, refreshing, initializing, error, etc.

A deprecated version of useQuery, please use useQuery instead.

Demo

Source

Immediate + Trigger by user + Dependencies

Data:
Loading...

Lifecycle + Refresh + Params + Mutate + Cancel

Data:
Not loaded
Params:
[]

Throttle + Debounce

Data with debounce:
Not loaded
Data with throttle:
Not loaded

ReFocus + ReConnect + AutoRefresh + Loading Slow

Data:
Initializing...

Error Retry + Cache (SWR)

Data:
Not loaded
Params:
[]
Data2:
Not loaded
Params2:
[]

Usage

See API for more details.

Source

Click links below to view source on GitHub.

API

const { run, data, loading, refreshing, initializing, error, cancel, refresh, mutate, loadingSlow, ...pausable } = useRequest(fetcher, options)

See useQuery for more details.

ON THIS PAGE