You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2018/11/29 03:16:14 UTC

[GitHub] hanahmily closed pull request #201: Update: fix endpoint search bug.

hanahmily closed pull request #201: Update: fix endpoint search bug.
URL: https://github.com/apache/incubator-skywalking-ui/pull/201
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/components/Page/Search/index.js b/src/components/Page/Search/index.js
index 31ecfe4..5cddb5a 100644
--- a/src/components/Page/Search/index.js
+++ b/src/components/Page/Search/index.js
@@ -15,26 +15,25 @@
  * limitations under the License.
  */
 
-import React, { PureComponent } from 'react';
+import React, { Component } from 'react';
 import { Select, Spin } from 'antd';
 import debounce from 'lodash.debounce';
 import request from '../../../utils/request';
 
 const { Option } = Select;
 
-export default class Search extends PureComponent {
+export default class Search extends Component {
   constructor(props) {
     super(props);
     this.lastFetchId = 0;
     this.originFetchServer = this.fetchServer;
     this.fetchServer = debounce(this.fetchServer, 800);
+    this.state = {
+      data: [],
+      fetching: false,
+    };
   }
 
-  state = {
-    data: [],
-    fetching: false,
-  };
-
   componentDidMount() {
     const {...propsData} = this.props;
     if (propsData.variables && Object.keys(propsData.variables).length > 0) {
@@ -54,7 +53,6 @@ export default class Search extends PureComponent {
       return;
     }
     const { url, query, variables = {}, transform } = this.props;
-    const {...stateData} = this.state;
     this.lastFetchId += 1;
     const fetchId = this.lastFetchId;
     this.setState({ data: [], fetching: true });
@@ -73,25 +71,26 @@ export default class Search extends PureComponent {
         return;
       }
       const list = body.data[Object.keys(body.data)[0]];
+      const that = this;
       this.setState({ data: transform ? list.map(transform) : list, fetching: false });
-      if (stateData.data.length < 1) {
+      if (that.state.data.length < 1) {
         return;
       }
       if (!key) {
-        this.handleSelect(stateData.data[0]);
+        this.handleSelect(that.state.data[0]);
         return;
       }
-      const option = stateData.data.find(_ => _.key === key);
+      const option = that.state.data.find(_ => _.key === key);
       if (!option) {
-        this.handleSelect(stateData.data[0]);
+        this.handleSelect(that.state.data[0]);
       }
     });
   };
 
   handleSelect = value => {
     const { onSelect } = this.props;
-    const { ...stateData } = this.state;
-    const selected = stateData.data.find(_ => _.key === value.key);
+    const that = this;
+    const selected = that.state.data.find(_ => _.key === value.key);
     onSelect(selected);
   };
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services