Skip to main content

useLayoutUpdate

It's similar to useUpdate, except it uses useIsomorphicLayoutEffect internally.

API

function useLayoutUpdate(
effect: React.EffectCallback,
deps?: React.DependencyList
): void;

Example

import React from "react";
import { useLayoutUpdate } from "@lilib/hooks";

function Example() {
const [signal, setSignal] = useState({});

useLayoutUpdate(() => {
console.log("Signal changed");
}, [signal]);

return <button onClick={() => setSignal({})}>Change signal</button>;
}