React Handy Hooks
Edit page
HomeReadme
hooks
useAccordionuseFormuseRequestStateActionsExampleuseToggle

useRequest

useRequest is a hook that is designed to handle request state. It uses useReducer under the hood and returns state and three actions to update it.

State

The return state has the following properties

  • loading
  • initialLoad
  • succeeded
  • error
  • data

Actions

loading

  • flips loading to true
  • flips succeeded to false
  • resets error to null

succeeded

  • flips loading to false
  • flips succeeded to true
  • flips initialLoad to false
  • populates data with the given argument

failed

  • flips loading to false
  • flips initialLoad to false
  • populates error with the given argument

fulfilled

  • flips loading to false
  • flips initialLoad to false

Example