Spooky Ghost Haunted Docs Toggle darkmode

Hooks: useLayoutEffect

The function signature is the same as useEffect, but the callback is being called synchronously after rendering. Therefore, updates scheduled inside useLayoutEffect will be flushed synchronously before the browser has a chance to paint.

Most of the time, it is preferable to use useEffect to avoid blocking visual updates.

API

useLayoutEffect

Parameters

callback

Effect

effecting callback

values

unknown[]

dependencies to the effect

Returns

void

Exports

import { useLayoutEffect } from 'haunted/lib/use-layout-effect';