react-memo-polyfill
v0.0.2
Published
React.memo polyfill
Downloads
9
Maintainers
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]. You can use this polyfill until you upgrade your components
Install
$ yarn add reactmemo
Usage
import memo from 'reactmemo'
function MyComponent(props) { }
memo(MyComponent)
Optionally pass your compare function
import memo from 'reactmemo'
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);