Skip to content

Instantly share code, notes, and snippets.

@oreqizer
Last active December 2, 2016 12:48
Show Gist options
  • Save oreqizer/a52ee42a0c2cd007908b304f8b09eb36 to your computer and use it in GitHub Desktop.
Save oreqizer/a52ee42a0c2cd007908b304f8b09eb36 to your computer and use it in GitHub Desktop.
A sample 'shouldComponentUpdate' function.
// ... code
shouldComponentUpdate(nextProps) {
const { geo, ...rest } = this.props;
const geoOk = geo.lat === nextProps.geo.lat && geo.lon === nextProps.geo.lon;
return !(geoOk && Object.keys(rest)
.reduce((acc, key) => acc && rest[key] === nextProps[key], true));
}
// ... code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment