Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

DevtoolsOfflineContext.ts

16 lines541 Bytes

1import { createContext, useContext } from 'solid-js'
2import type { DevtoolsOfflineState } from './types'
3​
4export const DevtoolsOfflineContext = createContext<DevtoolsOfflineState>()
5​
6/**
7 * Returns the devtools offline state provided by `DevtoolsOfflineProvider`.
8 *
9 * @returns The offline state.
10 * @throws {Error} If there is no `DevtoolsOfflineProvider` above.
11 */
12export function useDevtoolsOffline() {
13 const state = useContext(DevtoolsOfflineContext)
14 if (!state) throw new Error('Missing DevtoolsOfflineProvider')
15 return state