-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Open
Description
Hello team,
We have a base class for React components that we're beginning to use. It's like PureComponent but does deep comparison of JSON-like values (just objects, arrays, and primitives). The purpose is to avoid re-renders when inputs haven't changed, even when objects/arrays were reconstructed.
import React from 'react';
import { compareObj } from './deepCompare';
export default class PureDeepComponent extends React.Component {
shouldComponentUpdate(newProps, newState) {
return !(compareObj(this.props, newProps) && compareObj(this.state, newState));
}
}
I was surprised that something like this wasn't included in React, and I'm wondering what the team's thoughts are -- was there a good reason for not doing something like this?
Metadata
Metadata
Assignees
Labels
No labels