UNPKG

@tanstack/react-hotkeys

Version:

React adapter for TanStack Hotkeys

12 lines (10 loc) • 527 B
import { useEffect, useLayoutEffect } from "react"; // src/_useIsomorphicLayoutEffect.ts /** * `useLayoutEffect` in the browser, so registrations and scopes stop while a * Suspense boundary hides content it already showed (React keeps passive * effects then). React 18 warns when a server render calls `useLayoutEffect`, * so the server gets `useEffect`, which does not run there either. */ const useIsomorphicLayoutEffect = typeof document === "undefined" ? useEffect : useLayoutEffect; export { useIsomorphicLayoutEffect };