axios-hooks icon indicating copy to clipboard operation
axios-hooks copied to clipboard

Type error: MouseEvent using refetch and provided example from docs

Open beauwilliams opened this issue 2 years ago • 1 comments

Type error: Type '(config?: AxiosRequestConfig<any> | undefined, options?: RefetchOptions | undefined) => AxiosPromise<any>' is not assignable to type 'MouseEventHandler<HTMLButtonElement>'.
  Types of parameters 'config' and 'event' are incompatible.
    Type 'MouseEvent<HTMLButtonElement, MouseEvent>' has no properties in common with type 'AxiosRequestConfig<any>'.

  11 |   return (
  12 |     <div>
> 13 |       <button onClick={refetch}>refetch</button>
     |               ^
  14 |       <pre>{JSON.stringify(data, null, 2)}</pre>
  15 |     </div>
  16 |   )

beauwilliams avatar Jul 21 '22 01:07 beauwilliams

Would you like to send a PR? We support sending events to the refetch function for convenience (so it can be used in event handlers) but this is apparently not reflected in the types. It should be a fairly straightforward change.

simoneb avatar Jul 21 '22 08:07 simoneb

🎉 This issue has been resolved in version 4.0.0 🎉

The release is available on:

Your optic bot 📦🚀

github-actions[bot] avatar Sep 28 '22 17:09 github-actions[bot]