Skip to content
GaudiGaudi Design System home

Search documentation

Search every page, heading and paragraph.

useIsomorphicLayoutEffect

useLayoutEffect in the browser, useEffect on the server.

HooksState@gaudi/design-system/hooks/state/use-isomorphic-layout-effectView in StorybookSource

For measure-before-paint code in components that also render on the server. CodeBlock, EventCalendar and Flow use it.

Usage

import { useIsomorphicLayoutEffect } from '@gaudi/design-system/hooks';
useIsomorphicLayoutEffect(() => { setHeight(ref.current.scrollHeight);}, [content]);

Examples

Measure before paint

Storybook

API

1 option
1 return value

Accessibility

Measuring before paint avoids visible jumps that can disorient readers and move focus targets.

Notes

  • Prefer useEffect unless you must read layout before the browser paints.