improve component performance
This commit is contained in:
@@ -40,11 +40,8 @@ export class StackdriverPicker extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps: Props) {
|
shouldComponentUpdate(nextProps: Props) {
|
||||||
return (
|
const nextOptions = this.buildOptions(nextProps);
|
||||||
nextProps.selected !== this.props.selected ||
|
return nextProps.selected !== this.props.selected || !_.isEqual(nextOptions, this.state.options);
|
||||||
!_.isEqual(nextProps.options, this.props.options) ||
|
|
||||||
!_.isEqual(nextProps.templateVariables, this.props.templateVariables)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildOptions({ templateVariables = [], groupName = '', options }) {
|
buildOptions({ templateVariables = [], groupName = '', options }) {
|
||||||
@@ -89,9 +86,7 @@ export class StackdriverPicker extends React.Component<Props, State> {
|
|||||||
backspaceRemovesValue={false}
|
backspaceRemovesValue={false}
|
||||||
onChange={item => onChange(item.value)}
|
onChange={item => onChange(item.value)}
|
||||||
options={options}
|
options={options}
|
||||||
autoFocus={false}
|
|
||||||
isSearchable={searchable}
|
isSearchable={searchable}
|
||||||
openMenuOnFocus={true}
|
|
||||||
maxMenuHeight={500}
|
maxMenuHeight={500}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
noOptionsMessage={() => 'No options found'}
|
noOptionsMessage={() => 'No options found'}
|
||||||
|
|||||||
Reference in New Issue
Block a user