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

DevtoolsStateContext.ts

15 lines536 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 `DevtoolsStateProvider`.
8 * @returns The selection and panel state.
9 * @throws {Error} If there is no `DevtoolsStateProvider` above.
10 */
11export function useDevtoolsState() {
12 const state = useContext(DevtoolsStateContext)
13 if (!state) throw new Error('Missing DevtoolsStateProvider')
14 return state