useAdaptiveEffect
constuseAdaptiveEffect: typeofuseEffect
Defined in: hooks/dom/useAdaptiveEffect.ts:29
A hook that adapts to the environment: uses useLayoutEffect on the client side (when a DOM is available) and useEffect on the server side. This helps avoid React warnings such as "useLayoutEffect does nothing on the server".
See
- https://react.dev/reference/react/useEffect React useEffect documentation
- https://react.dev/reference/react/useLayoutEffect React useLayoutEffect documentation
Example
Just like useEffect, but it chooses the right hook depending on the environment.
tsx
useAdaptiveEffect(() => {
// Your effect code here
}, [dependencies]);