Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Andarist/use-isomorphic-layout-effect
https://github.com/Andarist/use-isomorphic-layout-effect
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Andarist/use-isomorphic-layout-effect
- Owner: Andarist
- License: mit
- Created: 2020-05-18T19:59:57.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-26T13:36:26.000Z (5 months ago)
- Last Synced: 2024-07-18T22:41:27.500Z (2 months ago)
- Language: TypeScript
- Size: 9.77 KB
- Stars: 25
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# use-isomorphic-layout-effect
A React helper hook for scheduling a layout effect with a fallback to a regular effect for environments where layout effects should not be used (such as server-side rendering).
## Installation
```sh
$ npm i use-isomorphic-layout-effect
```## Usage
You only need to switch `useLayoutEffect` with `useIsomorphicLayoutEffect`
```diff
+ import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect';
- import { useLayoutEffect } from 'react';const YourComponent = () => {
+ useIsomorphicLayoutEffect(() => {
- useLayoutEffect(() => {
// your implementation
}, []);
};
```