useStatus - rootstrap/redux-tools GitHub Wiki
If you are using the statusReducer you can check the status of an ongoing thunk with the useStatus hook. In case the status is ERROR you can also access de error object.
You can use the thunkAction object created with createThunk straight in the hook.
The status is one of the next four:
- NOT_STARTED
- LOADING
- SUCCESS
- ERROR
Each of these can be imported from the module.
Example
import { useStatus, ERROR } from '@rootstrap/redux-tools'
const MyComponent = () => {
const { status, error } = useStatus(getProfile)
if (status === ERROR) {
console.log(error)
}
...
}