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

context.ts

24 lines603 Bytes

1import { createContext, useContext } from 'solid-js'
2​
3export const ShadowDomTargetContext = createContext<ShadowRoot | undefined>(
4 undefined,
5)
6​
7export const DevtoolsOnCloseContext = createContext<
8 | {
9 onCloseClick: (
10 e: MouseEvent & { currentTarget: HTMLButtonElement; target: Element },
11 ) => void
12 }
13 | undefined
14>(undefined)
15​
16export const useDevtoolsOnClose = () => {
17 const context = useContext(DevtoolsOnCloseContext)
18 if (!context) {
19 throw new Error(
20 'useDevtoolsOnClose must be used within a TanStackRouterDevtools component',
21 )
22 }
23 return context