Browse Source

Fix incorrect React Component state assignment

master
Lyubo Marinov 7 years ago
parent
commit
1834fc63d2
1 changed files with 18 additions and 13 deletions
  1. 18
    13
      react/features/invite/components/InviteButton.web.js

+ 18
- 13
react/features/invite/components/InviteButton.web.js View File

75
      */
75
      */
76
     componentWillReceiveProps(nextProps) {
76
     componentWillReceiveProps(nextProps) {
77
         if (this.props._isDialOutAvailable !== nextProps._isDialOutAvailable
77
         if (this.props._isDialOutAvailable !== nextProps._isDialOutAvailable
78
-            || this.props._isAddToCallAvailable
79
-                !== nextProps._isAddToCallAvailable) {
78
+                || this.props._isAddToCallAvailable
79
+                    !== nextProps._isAddToCallAvailable) {
80
             this._updateInviteItems(nextProps);
80
             this._updateInviteItems(nextProps);
81
         }
81
         }
82
     }
82
     }
185
             );
185
             );
186
         }
186
         }
187
 
187
 
188
-        this.state = {
188
+        const nextState = {
189
             /**
189
             /**
190
              * The list of invite options.
190
              * The list of invite options.
191
              */
191
              */
195
                 }
195
                 }
196
             ]
196
             ]
197
         };
197
         };
198
+
199
+        if (this.state) {
200
+            this.setState(nextState);
201
+        } else {
202
+            // eslint-disable-next-line react/no-direct-mutation-state
203
+            this.state = nextState;
204
+        }
198
     }
205
     }
199
 }
206
 }
200
 
207
 
210
  * }}
217
  * }}
211
  */
218
  */
212
 function _mapStateToProps(state) {
219
 function _mapStateToProps(state) {
213
-    const { enableUserRolesBasedOnToken } = state['features/base/config'];
214
-
215
     const { conference } = state['features/base/conference'];
220
     const { conference } = state['features/base/conference'];
216
-
221
+    const { enableUserRolesBasedOnToken } = state['features/base/config'];
217
     const { isGuest } = state['features/jwt'];
222
     const { isGuest } = state['features/jwt'];
218
 
223
 
219
     return {
224
     return {
220
-        _isAddToCallAvailable: !isGuest
221
-            && isInviteOptionEnabled(ADD_TO_CALL_OPTION),
225
+        _isAddToCallAvailable:
226
+            !isGuest && isInviteOptionEnabled(ADD_TO_CALL_OPTION),
222
         _isDialOutAvailable:
227
         _isDialOutAvailable:
223
             getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR
228
             getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR
224
-            && conference && conference.isSIPCallingSupported()
225
-            && isInviteOptionEnabled(DIAL_OUT_OPTION)
226
-            && (!enableUserRolesBasedOnToken || !isGuest)
229
+                && conference && conference.isSIPCallingSupported()
230
+                && isInviteOptionEnabled(DIAL_OUT_OPTION)
231
+                && (!enableUserRolesBasedOnToken || !isGuest)
227
     };
232
     };
228
 }
233
 }
229
 
234
 
230
-export default translate(connect(
231
-    _mapStateToProps, { openDialog })(InviteButton));
235
+export default translate(connect(_mapStateToProps, { openDialog })(
236
+    InviteButton));

Loading…
Cancel
Save