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

Function createValue

packages/react-query/src/QueryErrorResetBoundary.tsx:45–68  ·  view source on GitHub ↗

* Creates the value shared through the boundary's context, which tracks whether a reset was * requested. * @returns The `clearReset`, `isReset`, and `reset` functions of the boundary.

()

Source from the content-addressed store, hash-verified

43 * @returns The `clearReset`, `isReset`, and `reset` functions of the boundary.
44 */
45function createValue(): QueryErrorResetBoundaryValue {
46 let isReset = false
47 return {
48 /**
49 * Clears the reset state, so queries know not to try again until the boundary is reset again.
50 */
51 clearReset: () => {
52 isReset = false
53 },
54 /**
55 * Resets any query errors within the boundary, so queries know they can try again.
56 */
57 reset: () => {
58 isReset = true
59 },
60 /**
61 * Returns whether the boundary has been reset and not yet cleared.
62 * @returns `true` if the boundary has been reset and not yet cleared.
63 */
64 isReset: () => {
65 return isReset
66 },
67 }
68}
69
70const QueryErrorResetBoundaryContext = React.createContext(createValue())
71

Callers 2

QueryErrorResetBoundaryFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected