- Notifications
You must be signed in to change notification settings - Fork1.3k
[@tanstack/react-query] Copy to react-query v5 to v4#4568
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
8 commits Select commitHold shift + click to select a range
f536629 copy v5 to v4
8f0e325 dont have tests run twice
146cb17 put back test
e32d767 change way tests a run
Brianzchend3447c4 update tests to show logs
Brianzchen23ce6ae check if this stablizes the test that consistently fails
Brianzchena8c67d7 fix tests
Brianzchenc004ded fix flow issues
BrianzchenFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
NextNext commit
copy v5 to v4
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
147 changes: 147 additions & 0 deletionsdefinitions/npm/@tanstack/react-query_v4.x.x/flow_v0.83.x-/react-query_v4.x.x.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| declare module "@tanstack/react-query" { | ||
| declare type QueryFunctionContext = { [key: string]: any }; | ||
| declare type UseQueryOptions<TData> = {| | ||
| queryKey: Array<any>, | ||
| queryFn?: (context: QueryFunctionContext) => Promise<TData>, | ||
| cacheTime?: any, | ||
| enabled?: any, | ||
| networkMode?: any, | ||
| initialData?: any, | ||
| initialDataUpdatedAt?: any, | ||
| keepPreviousData?: any, | ||
| meta?: any, | ||
| notifyOnChangeProps?: any, | ||
| onError?: any, | ||
| onSettled?: any, | ||
| onSuccess?: any, | ||
| placeholderData?: any, | ||
| queryKeyHashFn?: any, | ||
| refetchInterval?: any, | ||
| refetchIntervalInBackground?: any, | ||
| refetchOnMount?: any, | ||
| refetchOnReconnect?: any, | ||
| refetchOnWindowFocus?: any, | ||
| retry?: any, | ||
| retryOnMount?: any, | ||
| retryDelay?: any, | ||
| select?: any, | ||
| staleTime?: any, | ||
| structuralSharing?: any, | ||
| suspense?: any, | ||
| useErrorBoundary?: any, | ||
| |}; | ||
| declare type UseQueryReturn<TData, TError> = {| | ||
| isLoading: boolean, | ||
| data: TData, | ||
| dataUpdatedAt: number, | ||
| error: null | TError, | ||
| errorUpdatedAt: number, | ||
| failureCount: number, | ||
| failureReason: null | TError, | ||
| fetchStatus: any, | ||
| isError: boolean, | ||
| isFetched: boolean, | ||
| isFetchedAfterMount: boolean, | ||
| isFetching: boolean, | ||
| isInitialLoading: boolean, | ||
| isLoadingError: boolean, | ||
| isPaused: boolean, | ||
| isPending: boolean, | ||
| isPlaceholderData: boolean, | ||
| isRefetchError: boolean, | ||
| isRefetching: boolean, | ||
| isStale: boolean, | ||
| isSuccess: boolean, | ||
| refetch: any, | ||
| status: string, | ||
| |}; | ||
| declare type UseMutationOptions<TData, TError> = {| | ||
| mutationKey: Array<string>, | ||
| mutationFn: () => Promise<TData>, | ||
| onSuccess?: (data: TData, variables: any) => Promise<any>, | ||
| onError?: (error: TError) => Promise<any>, | ||
| onSettled?: (data: TData | void, error: TError | null, variables: any) => Promise<any>, | ||
| onMutate?: () => Promise<any>, | ||
| cacheTime?: any, | ||
| mutationKey?: any, | ||
| networkMode?: any, | ||
| retry?: any, | ||
| retryDelay?: any, | ||
| useErrorBoundary?: any, | ||
| meta?: any, | ||
| |} | ||
| declare type UseMutationReturn<TData, TError> = {| | ||
| data: TData | void, | ||
| error: TError | null, | ||
| isError: boolean, | ||
| isIdle: boolean, | ||
| isLoading: boolean, | ||
| isPaused: boolean, | ||
| isSuccess: boolean, | ||
| failureCount: number, | ||
| failureReason: TError | null, | ||
| mutate: ( | ||
| variables: any, | ||
| options?: {| | ||
| onError?: (error: TError) => Promise<any>, | ||
| onSettled?: (data: TData | void, error: TError | null, variables: any) => Promise<any>, | ||
| onSuccess?: (data: TData, variables: any) => Promise<any>, | ||
| |} | ||
| ) => Promise<any>, | ||
| mutateAsync: ( | ||
| variables: any, | ||
| options?: {| | ||
| onError?: (error: TError) => Promise<any>, | ||
| onSettled?: (data: TData | void, error: TError | null, variables: any) => Promise<any>, | ||
| onSuccess?: (data: TData, variables: any) => Promise<any>, | ||
| |} | ||
| ) => Promise<TData>, | ||
| reset: () => void, | ||
| status: string, | ||
| |}; | ||
| declare class QueryClient { | ||
| queryCache?: any, | ||
| mutationCache?: any, | ||
| defaultOptions?: any, | ||
| } | ||
| declare type QueryClientProviderOptions = {| | ||
| client: QueryClient, | ||
| children?: React$Node, | ||
| |}; | ||
| declare module.exports: {| | ||
| useQuery: <T = any, E = any>(queryOptions: UseQueryOptions<T>) => UseQueryReturn<T,E>, | ||
| useMutation: <T = any, E = any>(options: UseMutationOptions<T,E>) => UseMutationReturn<T,E>, | ||
| QueryClientProvider: (options: QueryClientProviderOptions) => React$Node, | ||
| QueryClient: typeof QueryClient, | ||
| useQueries: any, | ||
| useInfiniteQuery: any, | ||
| useIsFetching: any, | ||
| useIsMutating: any, | ||
| useMutationState: any, | ||
| useSuspenseQuery: any, | ||
| useSuspenseInfiniteQuery: any, | ||
| useSuspenseQueries: any, | ||
| useQueryClient: any, | ||
| queryOptions: any, | ||
| infiniteQueryOptions: any, | ||
| QueryCache: any, | ||
| MutationCache: any, | ||
| QueryObserver: any, | ||
| InfiniteQueryObserver: any, | ||
| QueriesObserver: any, | ||
| QueryErrorResetBoundary: any, | ||
| useQueryErrorResetBoundary: any, | ||
| focusManager: any, | ||
| onlineManager: any, | ||
| dehydrate: any, | ||
| hydrate: any, | ||
| HydrationBoundary : any, | ||
| |}; | ||
| } |
80 changes: 80 additions & 0 deletionsdefinitions/npm/@tanstack/react-query_v4.x.x/flow_v0.83.x-/test_react-query_v4.x.x.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import * as React from 'react'; | ||
| import { describe, test } from 'flow-typed-test'; | ||
| import { useQuery, QueryClientProvider, useMutation, QueryClient } from '@tanstack/react-query'; | ||
| describe('react-query', ()=> { | ||
| test('UseQuery', () => { | ||
| // Correct usage | ||
| const { isLoading, isSuccess, data } = useQuery({ | ||
| queryKey: ['example'], | ||
| queryFn: async () => { | ||
| const response = await fetch('https://api.example.com/data'); | ||
| const data = await response.json(); | ||
| return data; | ||
| }, | ||
| }); | ||
| (isLoading: boolean); | ||
| (isSuccess: boolean); | ||
| // Incorrect usage | ||
| useQuery({ | ||
| // $FlowExpectedError[incompatible-call] | ||
| queryKey: 123, // Error: Array<string> | ||
| queryFn: () => { | ||
| // $FlowExpectedError[incompatible-call] | ||
| return 'not a promise'; // Error: Promise is required | ||
| }, | ||
| }); | ||
| }); | ||
| test('UseMutation', () => { | ||
| // Correct usage | ||
| const {isLoading, isSuccess } = useMutation({ | ||
| mutationKey: ['example'], | ||
| mutationFn: async () => { | ||
| const response = await fetch('https://api.example.com/mutate'); | ||
| const data = await response.json(); | ||
| return data; | ||
| }, | ||
| onSuccess: async (data, variables) => await console.log(data, variables), | ||
| onError: async (error) => await console.error(error), | ||
| onSettled: async (data, error, variables) => await console.log(data, error, variables), | ||
| onMutate: async () => await console.log('onMutate callback'), | ||
| }); | ||
| (isLoading: boolean); | ||
| (isSuccess: boolean); | ||
| // Incorrect usage | ||
| useMutation({ | ||
| mutationKey: 123, // Error: Expected Array<string> | ||
| mutationFn: () => { | ||
| // $FlowExpectedError[incompatible-call] | ||
| return 'not a promise'; // Error: Promise is required | ||
| }, | ||
| onSuccess: () => { | ||
| // $FlowExpectedError[incompatible-call] | ||
| return 'not a promise'; // Error: Promise is required | ||
| }, | ||
| onError: () => { | ||
| // $FlowExpectedError[incompatible-call] | ||
| return 'not a promise'; // Error: Promise is required | ||
| }, | ||
| onSettled: () => { | ||
| // $FlowExpectedError[incompatible-call] | ||
| return 'not a promise'; // Error: Promise is required | ||
| }, | ||
| onMutate: () => { | ||
| // $FlowExpectedError[incompatible-call] | ||
| return 'not a promise'; // Error: Promise is required | ||
| }, | ||
| }); | ||
| }); | ||
| test('QueryClientProvider', () => { | ||
| // Correct usage | ||
| const queryClient = new QueryClient(); | ||
| <QueryClientProvider client={queryClient}><div /></QueryClientProvider>; | ||
| }); | ||
| }) |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.