Răsfoiți Sursa

Initial state as private member variable

Taichi Masuyama 4 ani în urmă
părinte
comite
9514fced7a

+ 9 - 6
packages/app/src/components/Admin/UserGroup/UserGroupDeleteModal.tsx

@@ -32,10 +32,6 @@ type State = {
   actionName: string,
   actionName: string,
   transferToUserGroupId: string,
   transferToUserGroupId: string,
 };
 };
-const initialState = {
-  actionName: '',
-  transferToUserGroupId: '',
-};
 
 
 class UserGroupDeleteModal extends React.Component<Props, State> {
 class UserGroupDeleteModal extends React.Component<Props, State> {
 
 
@@ -47,6 +43,8 @@ class UserGroupDeleteModal extends React.Component<Props, State> {
 
 
   state: State;
   state: State;
 
 
+  private initialState: State;
+
   constructor(props) {
   constructor(props) {
     super(props);
     super(props);
 
 
@@ -83,7 +81,12 @@ class UserGroupDeleteModal extends React.Component<Props, State> {
       },
       },
     ];
     ];
 
 
-    this.state = initialState;
+    this.initialState = {
+      actionName: '',
+      transferToUserGroupId: '',
+    };
+
+    this.state = this.initialState;
 
 
     this.xss = (window as CustomWindow).xss;
     this.xss = (window as CustomWindow).xss;
 
 
@@ -101,7 +104,7 @@ class UserGroupDeleteModal extends React.Component<Props, State> {
       return;
       return;
     }
     }
 
 
-    this.setState(initialState);
+    this.setState(this.initialState);
     this.props.onHide();
     this.props.onHide();
   }
   }