useIsomorphicEffect
Aboutβ
A hook that resolves to useEffect on the server and useLayoutEffect on the client.
Installationβ
npm install --save rooks
Importing the hookβ
import { useIsomorphicEffect } from "rooks";
Usageβ
function Demo() {
useIsomorphicEffect(() => {
console.log("Effect");
}, []);
return null;
}
render(<Demo />);
Argumentsβ
Argument value | Type | Description |
---|---|---|
callback | function | Callback function to be called on mount |
Returnsβ
Returns useEffect
when "window" is not in scope and useLayoutEffect
in the browser
Codesandbox Examplesβ
Basic Usageβ
Join Bhargav's discord serverβ
You can click on the floating discord icon at the bottom right of the screen and talk to us in our server.