Skip to Content
HooksHooksuseIsomorphicLayoutEffect

useIsomorphicLayoutEffect

Description

Use useIsomorphicLayoutEffect to run layout effects in both the server and the client. This hook runs useLayoutEffect on the client and useEffect on the server.

Parameters

No parameters

Example

Inspect

Source code

/packages/react-hooks/hooks/useIsomorphicLayoutEffect.ts
import { useEffect, useLayoutEffect } from 'react' /** * Use `useIsomorphicLayoutEffect` to run layout effects in both the server and the client. * * This hook runs `useLayoutEffect` on the client and `useEffect` on the server. * @public */ export const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect
Last updated on