Created
November 11, 2019 16:18
-
-
Save nirsky/d2c2bea17969a661a65acd8cd4cc80a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Class | |
shouldComponentUpdate(nextProps) { | |
return nextProps.count !== this.props.count | |
} | |
//memo | |
import React, { memo } from 'react'; | |
const MyComponent = memo( | |
_MyComponent, | |
// Notice condition is inversed from shouldComponentUpdate | |
(prevProps, nextProps) => nextProps.count === prevProps.count | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment