Browse Source

添加症状标签内存溢出bug修改2423

zhouna 5 năm trước cách đây
mục cha
commit
6535a70c71

+ 0 - 1
src/common/components/SearchBox/index.jsx

@@ -101,7 +101,6 @@ class SearchBox extends React.Component {
     }
     componentWillReceiveProps(next){
       // 隐藏时,清空搜索框内文字,清空搜索结果,隐藏搜索框
-      const { clearSearch } = this.props;
       if(!next.show && next.show != this.props.show){
         this.reset();
       }

+ 4 - 1
src/store/reducers/mainSuit.js

@@ -123,7 +123,10 @@ export default function(state=initState,action){
       res.addSearchData = action.data;
       return res;
     case CLEAR_ADD_SEARCH://清空症状搜索结果
-      res.addSearchData = [];
+      //非必要是不要重复赋值[],造成searchBox componentWillReceiveProps循环调用导致内存泄漏
+      if(res.addSearchData&&res.addSearchData.length>0){
+        res.addSearchData = [];
+      }
       return res;
     default:
       return state;