Skip to content
Closed
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions docs/src/pages/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const {
refetchInterval,
refetchIntervalInBackground,
queryFnParamsFilter,
refetchOnMount,
isDataEqual,
onError,
onSuccess,
Expand Down Expand Up @@ -112,10 +111,6 @@ const queryInfo = useQuery({
- Optional
- If set, this will mark any `initialData` provided as stale and will likely cause it to be refetched on mount
- If a function is passed, it will be called only when appropriate to resolve the `initialStale` value. This can be useful if your `initialStale` value is costly to calculate.
- `refetchOnMount: Boolean`
- Optional
- Defaults to `true`
- If set to `false`, will disable additional instances of a query to trigger background refetches
- `queryFnParamsFilter: Function(args) => filteredArgs`
- Optional
- This function will filter the params that get passed to `queryFn`.
Expand Down Expand Up @@ -664,7 +659,6 @@ const queryConfig = {
refetchOnWindowFocus: true,
refetchInterval: false,
queryFnParamsFilter: identity,
refetchOnMount: true,
isDataEqual: deepEqual,
onError: noop,
onSuccess: noop,
Expand Down
1 change: 0 additions & 1 deletion src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const DEFAULT_CONFIG = {
refetchOnWindowFocus: true,
refetchInterval: false,
queryFnParamsFilter: identity,
refetchOnMount: true,
isDataEqual: deepEqual,
onError: noop,
onSuccess: noop,
Expand Down
8 changes: 3 additions & 5 deletions src/core/queryInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ export function makeQueryInstance(query, onStateUpdate) {

instance.run = async () => {
try {
// Perform the refetch for this query if necessary
if (
if(
query.config.enabled && // Don't auto refetch if disabled
!query.wasSuspended && // Don't double refetch for suspense
query.state.isStale && // Only refetch if stale
(query.config.refetchOnMount || query.instances.length === 1)
query.state.isStale // Only refetch if stale
) {
await query.fetch()
await query.fetch();
}

query.wasSuspended = false
Expand Down
6 changes: 1 addition & 5 deletions src/react/tests/ReactQueryConfigProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ describe('ReactQueryConfigProvider', () => {
const config = {
queries: {
refetchOnWindowFocus: false,
refetchOnMount: false,
retry: false,
},
}
Expand Down Expand Up @@ -143,7 +142,7 @@ describe('ReactQueryConfigProvider', () => {
await waitFor(() => rendered.findByText('Data: data'))

// tear down and unmount
// so we are NOT passing the config above (refetchOnMount should be `true` by default)
// so we are NOT passing the config above
fireEvent.click(rendered.getByText('unmount'))

act(() => {
Expand All @@ -161,15 +160,12 @@ describe('ReactQueryConfigProvider', () => {

const parentConfig = {
queries: {
refetchOnMount: false,
onSuccess: parentOnSuccess,
},
}

const childConfig = {
queries: {
refetchOnMount: true,

// Override onSuccess of parent, making it a no-op
onSuccess: undefined,
},
Expand Down
1 change: 0 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ export interface BaseQueryOptions<TResult = unknown, TError = Error> {
refetchInterval?: false | number
refetchIntervalInBackground?: boolean
refetchOnWindowFocus?: boolean
refetchOnMount?: boolean
onSuccess?: (data: TResult) => void
onError?: (err: TError) => void
onSettled?: (data: TResult | undefined, error: TError | null) => void
Expand Down