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

DevtoolsOfflineContext.ts

15 lines538 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 * @returns The offline state.
9 * @throws {Error} If there is no `DevtoolsOfflineProvider` above.
10 */
11export function useDevtoolsOffline() {
12 const state = useContext(DevtoolsOfflineContext)
13 if (!state) throw new Error('Missing DevtoolsOfflineProvider')
14 return state