From 1834fc63d2df7c34414fff3de1b10b00053ee0d6 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Tue, 3 Oct 2017 14:43:05 -0500 Subject: [PATCH] Fix incorrect React Component state assignment --- .../invite/components/InviteButton.web.js | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/react/features/invite/components/InviteButton.web.js b/react/features/invite/components/InviteButton.web.js index f83e7bc83..223ae96ac 100644 --- a/react/features/invite/components/InviteButton.web.js +++ b/react/features/invite/components/InviteButton.web.js @@ -75,8 +75,8 @@ class InviteButton extends Component { */ componentWillReceiveProps(nextProps) { if (this.props._isDialOutAvailable !== nextProps._isDialOutAvailable - || this.props._isAddToCallAvailable - !== nextProps._isAddToCallAvailable) { + || this.props._isAddToCallAvailable + !== nextProps._isAddToCallAvailable) { this._updateInviteItems(nextProps); } } @@ -185,7 +185,7 @@ class InviteButton extends Component { ); } - this.state = { + const nextState = { /** * The list of invite options. */ @@ -195,6 +195,13 @@ class InviteButton extends Component { } ] }; + + if (this.state) { + this.setState(nextState); + } else { + // eslint-disable-next-line react/no-direct-mutation-state + this.state = nextState; + } } } @@ -210,22 +217,20 @@ class InviteButton extends Component { * }} */ function _mapStateToProps(state) { - const { enableUserRolesBasedOnToken } = state['features/base/config']; - const { conference } = state['features/base/conference']; - + const { enableUserRolesBasedOnToken } = state['features/base/config']; const { isGuest } = state['features/jwt']; return { - _isAddToCallAvailable: !isGuest - && isInviteOptionEnabled(ADD_TO_CALL_OPTION), + _isAddToCallAvailable: + !isGuest && isInviteOptionEnabled(ADD_TO_CALL_OPTION), _isDialOutAvailable: getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR - && conference && conference.isSIPCallingSupported() - && isInviteOptionEnabled(DIAL_OUT_OPTION) - && (!enableUserRolesBasedOnToken || !isGuest) + && conference && conference.isSIPCallingSupported() + && isInviteOptionEnabled(DIAL_OUT_OPTION) + && (!enableUserRolesBasedOnToken || !isGuest) }; } -export default translate(connect( - _mapStateToProps, { openDialog })(InviteButton)); +export default translate(connect(_mapStateToProps, { openDialog })( + InviteButton));