* 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.
()
| 43 | * @returns The `clearReset`, `isReset`, and `reset` functions of the boundary. |
| 44 | */ |
| 45 | function 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 | |
| 70 | const QueryErrorResetBoundaryContext = React.createContext(createValue()) |
| 71 |
no outgoing calls
no test coverage detected