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