浏览代码

箭头函数传值性能问题修改

zhouna 6 年之前
父节点
当前提交
758555c01c

+ 1 - 1
src/components/AddAssistCheck/index.jsx

@@ -140,7 +140,7 @@ class AddAssistCheck extends React.Component {
                 </div>
                 <ConfirmModal 
                     visible={visible}
-                    confirm={()=>{this.delConfirm()}}
+                    confirm={this.delConfirm}
                     close={this.handleCancel}
                     cancel={this.handleCancel}
                     okText="删除"

+ 1 - 1
src/components/AddInspect/index.jsx

@@ -385,7 +385,7 @@ class Inspect extends React.Component {
                 </div>
                 <ConfirmModal 
                     visible={visible}
-                    confirm={()=>{this.delConfirm()}}
+                    confirm={this.delConfirm}
                     close={this.handleCancel}
                     cancel={this.handleCancel}
                     okText="删除"

+ 7 - 3
src/components/HistoryCaseContainer/index.jsx

@@ -12,6 +12,7 @@ import { CONFIRM_TYPE } from "@store/types/typeConfig";
 class HistoryCaseContainer extends React.Component {
     constructor(props){
         super(props);
+        this.close = this.close.bind(this);
     }
     componentDidMount(){
         // store.dispatch(initItemList());
@@ -24,6 +25,9 @@ class HistoryCaseContainer extends React.Component {
         store.dispatch({type: CONFIRM_TYPE, confirmType: baseObj.sign});
         pushAllDataList(baseObj.sign,'push',baseObj,'history')       //引用
     }
+    close(){
+      store.dispatch(visibleHistory(false));
+    }
     render(){
         const { visible,showHistoryCases,showHistoryBox,items,handleCaseClick,handleQuoteClick,handleSortClick,activeHistory,preInfo } = this.props;
         const domNode = document.getElementById('root');
@@ -41,9 +45,9 @@ class HistoryCaseContainer extends React.Component {
                 ></HistoryList>
                 <ConfirmModal 
                     visible={visible}
-                    confirm={()=>{this.makeSure()}}
-                    close={()=>{store.dispatch(visibleHistory(false))}}
-                    cancel={()=>{store.dispatch(visibleHistory(false))}}
+                    confirm={this.makeSure}
+                    close={this.close}
+                    cancel={this.close}
                     okText={"引用"}
                     okBorderColor={'#3B9ED0'}
                     okColor={'#fff'}

+ 7 - 3
src/components/PushContainer/index.jsx

@@ -46,6 +46,7 @@ class PushContainer extends Component {
         this.handleAllCheckbox=this.handleAllCheckbox.bind(this)
         this.handleMangerTemplate=this.handleMangerTemplate.bind(this)
         this.handleDelList=this.handleDelList.bind(this)
+        this.handleClose = this.handleClose.bind(this);
     }
     componentDidMount(){
         // const height = getWindowInnerHeight()-160;
@@ -219,6 +220,9 @@ class PushContainer extends Component {
         }
         store.dispatch(changeVisible(false))
     }
+    handleClose(){
+      store.dispatch(changeVisible(false));
+    }
     render() {
         const {activeId,checkItems,visible,showMsg,items,allCheckShow} = this.props;
         return <div className={style["container"]} ref={this.$cont} >
@@ -243,9 +247,9 @@ class PushContainer extends Component {
             </Tab>
             <ConfirmModal 
                 visible={visible}
-                confirm={()=>{this.makeSure()}}
-                close={()=>{store.dispatch(changeVisible(false))}}
-                cancel={()=>{store.dispatch(changeVisible(false))}}
+                confirm={this.makeSure}
+                close={this.handleClose}
+                cancel={this.handleClose}
                 okText={this.state.okText}
                 okBorderColor={this.state.okBorderColor}
                 okColor={this.state.okColor}