Collection of useful React Hooks

Usage no npm install needed!

<script type="module">
  import lyonphReactHooks from 'https://cdn.skypack.dev/@lyonph/react-hooks';



  • useCallbackCondition: Memoizes a callback function conditionally.
  • useConstant: Creates a component-level constant.
  • useConstantCallback: Creates a component-level constant callback.
  • useForceUpdate: Creates a callback that re-renders the component when called.
  • useFreshLazyRef:
  • useFreshState: useState but resets to initial state when dependency changes.
  • useFullscreenElement: Tracks document.fullscreenElement.
  • useIsomorphicEffect: SSR-friendly useLayoutEffect.
  • useLazyRef: useRef but with initializer callback.
  • useMediaQuery: Tracks media query match.
  • useMemoCondition: Memoizes conditionally.
  • useMountedState: Creates a callback that tracks the lifecycle state of the component.
  • useOnlineStatus: Tracks navigator.onLine.
  • usePageVisibility: Tracks document.visibilityState.
  • usePrefersDarkTheme
  • usePrefersLightTheme
  • usePrefersReducedMotion
  • useReadyState
  • useRenderCount
  • useSubscription
  • useWindowScroll
  • useWindowSize