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

DevtoolsStateContext.ts

17 lines542 Bytes

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