Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mkanenobu/use-client-memo
https://github.com/mkanenobu/use-client-memo
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mkanenobu/use-client-memo
- Owner: mkanenobu
- Created: 2022-03-20T05:16:50.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-20T05:29:00.000Z (almost 3 years ago)
- Last Synced: 2024-12-16T01:37:41.315Z (24 days ago)
- Language: TypeScript
- Size: 122 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# use-client-memo
use-client-memo is a library for useMemo in Serverside rendering framework.
## Installation
```shell
npm install --save use-client-memo
# or
yarn add use-client-memo
```## Usage
```typescript
const Component = () => {
// this raises error trying to reference undefined "window"
// on server side rendering// const windowArea = useMemo(() => {
// return window.innerWidth * window.innerHeight;
// }, []);// this works on server side rendering
const windowArea = useClientMemo(() => {
return window.innerWidth * window.innerHeight;
}, 0, []);
}
```