浏览代码

improve component performance

Erik Sundell 7 年之前
父节点
当前提交
8e9cd83ee8
共有 1 个文件被更改,包括 2 次插入7 次删除
  1. 2 7
      public/app/plugins/datasource/stackdriver/components/StackdriverPicker.tsx

+ 2 - 7
public/app/plugins/datasource/stackdriver/components/StackdriverPicker.tsx

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