angelle-sw / use-axios-client

Make axios requests in React using hooks.
https://use-axios-client.io
MIT License
157 stars 7 forks source link

How to clear an error? #100

Open hakubo opened 4 years ago

hakubo commented 4 years ago

I have a

const [
  getData, { error }
] = useLazyAxios({
  url: `path`,
});

and when an error occurs I'd love to show a dialog sth like this:

<Button onClick={() => getData()}>Get Data</Button>
<Dialog
  open={!!error}
  onClose={/* how to close the dialog now? */}
>
...content...
</Dialog>

now I'd love to add the onClose handler to let a user close the dialog, but how to do this? Is making a successful request the only way to clear the error?