useLayoutMount

This Hook is available since v1.2.0.

A React Hooks that is similar to useMount but use useIsomorphicLayoutEffect under the hood.

Demo

Open DevTools to see the logs.

Source
useLayoutMount
useMount

Usage

See API for more details.

Source

Click links below to view source on GitHub.

API

useLayoutMount(callback, strictOnce)

Callback

A function that will be called when the component mounts (useLayoutEffect), can be async.

StrictOnce

Warning

strictOnce option is NOT recommended as it damages the original intention of the Strict Mode of React 18.

A boolean that indicates whether the handler should be called only once in Strict Mode of React 18. Default is false.