Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix No bound mutate returned by useRequest hook. #410

Merged
merged 1 commit into from
May 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/axios-typescript/libs/useRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type GetRequest = AxiosRequestConfig | null
interface Return<Data, Error>
extends Pick<
responseInterface<AxiosResponse<Data>, AxiosError<Error>>,
'isValidating' | 'revalidate' | 'error'
'isValidating' | 'revalidate' | 'error' | 'mutate'
> {
data: Data | undefined
response: AxiosResponse<Data> | undefined
Expand All @@ -24,7 +24,7 @@ export default function useRequest<Data = unknown, Error = unknown>(
request: GetRequest,
{ initialData, ...config }: Config<Data, Error> = {}
): Return<Data, Error> {
const { data: response, error, isValidating, revalidate } = useSWR<
const { data: response, error, isValidating, revalidate, mutate } = useSWR<
AxiosResponse<Data>,
AxiosError<Error>
>(
Expand Down Expand Up @@ -52,6 +52,7 @@ export default function useRequest<Data = unknown, Error = unknown>(
response,
error,
isValidating,
revalidate
revalidate,
mutate
}
}