https://github.com/zzarcon/react-memo
React.memo polyfill
https://github.com/zzarcon/react-memo
memo memoization polyfill react react-memo
Last synced: about 2 months ago
JSON representation
React.memo polyfill
- Host: GitHub
- URL: https://github.com/zzarcon/react-memo
- Owner: zzarcon
- License: mit
- Created: 2019-02-19T10:32:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-19T11:32:57.000Z (over 6 years ago)
- Last Synced: 2025-03-18T13:09:45.191Z (3 months ago)
- Topics: memo, memoization, polyfill, react, react-memo
- Language: TypeScript
- Size: 143 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-memo
> React.memo polyfill* What: https://reactjs.org/docs/react-api.html#reactmemo
* Why: https://medium.com/@trekinbami/using-react-memo-and-memoization-1970eb1ed128
* When: **React.memo** was introduced in [[email protected]](https://github.com/facebook/react/blob/master/CHANGELOG.md#1660-october-23-2018). You can use this polyfill until you upgrade your components### Install
```
$ yarn add react-memo-polyfill
```### Usage
```javascript
import memo from 'react-memo-polyfill'function MyComponent(props) { }
memo(MyComponent)
```Optionally pass your compare function
```javascript
import memo from 'react-memo-polyfill'function MyComponent(props) { }
function areEqual(prevProps, nextProps) {
/*
return true if passing nextProps to render would return
the same result as passing prevProps to render,
otherwise return false
*/
}
export default memo(MyComponent, areEqual);
```### Author
[@zzarcon](https://twitter.com/zzarcon)