UNPKG

@tanstack/react-hotkeys

Version:

React adapter for TanStack Hotkeys

20 lines (17 loc) • 628 B
'use client'; import { useHotkeysContext } from "./HotkeysProvider.js"; import { useSelector } from "./_useSelector.js"; import { createStore } from "@tanstack/hotkeys/adapter"; //#region src/_appHotkeysStore.ts const NO_APP_HOTKEYS = createStore(null); /** * The provider's app hotkeys store, re-rendering when app hotkeys or custom * hotkeys change. Null outside a provider with `appHotkeys`. */ function useAppHotkeysStoreState() { const store = useHotkeysContext()?.appHotkeysStore ?? null; useSelector(store?.store ?? NO_APP_HOTKEYS, (state) => state); return store; } //#endregion export { useAppHotkeysStoreState };