MCPcopy Create free account
hub / github.com/TanStack/query / setData

Method setData

packages/query-core/src/query.ts:312–327  ·  view source on GitHub ↗

@internal

(
    newData: TData,
    options?: SetDataOptions & { manual: boolean },
  )

Source from the content-addressed store, hash-verified

310
311 /** @internal */
312 setData(
313 newData: TData,
314 options?: SetDataOptions & { manual: boolean },
315 ): TData {
316 const data = replaceData(this.state.data, newData, this.options)
317
318 // Set data and mark it as cached
319 this.#dispatch({
320 data,
321 type: 'success',
322 dataUpdatedAt: options?.updatedAt,
323 manual: options?.manual,
324 })
325
326 return data
327 }
328
329 /**
330 * Merges the given partial state directly into this query's state, notifying observers. Used

Callers 5

fetchMethod · 0.95
setQueryDataMethod · 0.80
predicateFunction · 0.80
query.test-d.tsxFile · 0.80

Calls 2

#dispatchMethod · 0.95
replaceDataFunction · 0.90

Tested by 1

predicateFunction · 0.64