Open History to see the last commit
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
15}