Skip to content

Instantly share code, notes, and snippets.

@nirsky
Created November 11, 2019 16:18
Show Gist options
  • Save nirsky/d2c2bea17969a661a65acd8cd4cc80a5 to your computer and use it in GitHub Desktop.
Save nirsky/d2c2bea17969a661a65acd8cd4cc80a5 to your computer and use it in GitHub Desktop.
//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