UNPKG

@tanstack/react-hotkeys

Version:

React adapter for TanStack Hotkeys

17 lines (15 loc) • 565 B
import { useHotkeysContext } from "./HotkeysProvider.js"; import { Store, useSelector } from "@tanstack/react-store"; //#region src/_appHotkeysStore.ts const NO_APP_HOTKEYS = new Store(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 };