Bladeren bron

Merge pull request #3584 from virtuacoplenny/lenny/update-lifecycles-1

Remove some usages of deprecated lifecycle methods
master
virtuacoplenny 6 jaren geleden
bovenliggende
commit
f349357d3c
No account linked to committer's email address
29 gewijzigde bestanden met toevoegingen van 269 en 370 verwijderingen
  1. 1
    1
      android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java
  2. 1
    1
      ios/sdk/src/JitsiMeetView.m
  3. 12
    12
      react/features/always-on-top/AlwaysOnTop.js
  4. 2
    2
      react/features/base/dialog/components/AbstractDialog.js
  5. 32
    67
      react/features/base/dialog/components/StatelessDialog.web.js
  6. 11
    4
      react/features/base/label/components/CircularLabel.native.js
  7. 16
    7
      react/features/base/react/components/native/SideBar.js
  8. 11
    1
      react/features/base/toolbox/components/AbstractButton.js
  9. 4
    12
      react/features/deep-linking/components/DeepLinkingMobilePage.web.js
  10. 27
    39
      react/features/desktop-picker/components/DesktopPicker.js
  11. 3
    3
      react/features/device-selection/components/AudioInputPreview.js
  12. 8
    17
      react/features/device-selection/components/DeviceSelection.js
  13. 24
    34
      react/features/invite/components/InfoDialogButton.web.js
  14. 22
    22
      react/features/invite/components/info-dialog/InfoDialog.web.js
  15. 11
    14
      react/features/invite/components/info-dialog/PasswordForm.web.js
  16. 13
    16
      react/features/large-video/components/Labels.web.js
  17. 4
    6
      react/features/large-video/components/LargeVideoBackground.web.js
  18. 2
    2
      react/features/mobile/audio-mode/components/AudioRoutePickerDialog.js
  19. 15
    8
      react/features/recording/components/AbstractRecordingLabel.js
  20. 1
    30
      react/features/recording/components/LiveStream/AbstractStreamKeyForm.js
  21. 1
    1
      react/features/recording/components/LiveStream/native/StreamKeyForm.js
  22. 10
    20
      react/features/recording/components/LiveStream/web/LiveStreamButton.js
  23. 1
    1
      react/features/recording/components/LiveStream/web/StreamKeyForm.js
  24. 5
    15
      react/features/recording/components/Recording/web/RecordButton.js
  25. 8
    11
      react/features/speaker-stats/components/SpeakerStats.js
  26. 5
    5
      react/features/toolbox/components/web/Toolbox.js
  27. 14
    14
      react/features/welcome/components/AbstractWelcomePage.js
  28. 1
    1
      react/features/welcome/components/BlankPage.native.js
  29. 4
    4
      react/features/welcome/components/WelcomePage.native.js

+ 1
- 1
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java Bestand weergeven

@@ -262,7 +262,7 @@ public class JitsiMeetView
262 262
         // the respective conference again if the first invocation was followed
263 263
         // by leaving the conference. However, React and, respectively,
264 264
         // appProperties/initialProperties are declarative expressions i.e. one
265
-        // and the same URL will not trigger componentWillReceiveProps in the
265
+        // and the same URL will not trigger an automatic re-render in the
266 266
         // JavaScript source code. The workaround implemented bellow introduces
267 267
         // imperativeness in React Component props by defining a unique value
268 268
         // per loadURLObject: invocation.

+ 1
- 1
ios/sdk/src/JitsiMeetView.m Bestand weergeven

@@ -268,7 +268,7 @@ static NSMapTable<NSString *, JitsiMeetView *> *views;
268 268
     // conference again if the first invocation was followed by leaving the
269 269
     // conference. However, React and, respectively,
270 270
     // appProperties/initialProperties are declarative expressions i.e. one and
271
-    // the same URL will not trigger componentWillReceiveProps in the JavaScript
271
+    // the same URL will not trigger an automatic re-render in the JavaScript
272 272
     // source code. The workaround implemented bellow introduces imperativeness
273 273
     // in React Component props by defining a unique value per loadURLObject:
274 274
     // invocation.

+ 12
- 12
react/features/always-on-top/AlwaysOnTop.js Bestand weergeven

@@ -205,6 +205,18 @@ export default class AlwaysOnTop extends Component<*, State> {
205 205
         this._hideToolbarAfterTimeout();
206 206
     }
207 207
 
208
+    /**
209
+     * Sets a timeout to hide the toolbar when the toolbar is shown.
210
+     *
211
+     * @inheritdoc
212
+     * @returns {void}
213
+     */
214
+    componentDidUpdate(prevProps: *, prevState: State) {
215
+        if (!prevState.visible && this.state.visible) {
216
+            this._hideToolbarAfterTimeout();
217
+        }
218
+    }
219
+
208 220
     /**
209 221
      * Removes all listeners.
210 222
      *
@@ -223,18 +235,6 @@ export default class AlwaysOnTop extends Component<*, State> {
223 235
         window.removeEventListener('mousemove', this._mouseMove);
224 236
     }
225 237
 
226
-    /**
227
-     * Sets a timeout to hide the toolbar when the toolbar is shown.
228
-     *
229
-     * @inheritdoc
230
-     * @returns {void}
231
-     */
232
-    componentWillUpdate(nextProps: *, nextState: State) {
233
-        if (!this.state.visible && nextState.visible) {
234
-            this._hideToolbarAfterTimeout();
235
-        }
236
-    }
237
-
238 238
     /**
239 239
      * Implements React's {@link Component#render()}.
240 240
      *

+ 2
- 2
react/features/base/dialog/components/AbstractDialog.js Bestand weergeven

@@ -49,12 +49,12 @@ export default class AbstractDialog<P : Props, S : State>
49 49
     }
50 50
 
51 51
     /**
52
-     * Implements React's {@link Component#componentWillMount()}. Invoked
52
+     * Implements React's {@link Component#componentDidMount()}. Invoked
53 53
      * immediately before mounting occurs.
54 54
      *
55 55
      * @inheritdoc
56 56
      */
57
-    componentWillMount() {
57
+    componentDidMount() {
58 58
         this._mounted = true;
59 59
     }
60 60
 

+ 32
- 67
react/features/base/dialog/components/StatelessDialog.web.js Bestand weergeven

@@ -102,26 +102,8 @@ class StatelessDialog extends Component<Props> {
102 102
         this._onDialogDismissed = this._onDialogDismissed.bind(this);
103 103
         this._onKeyDown = this._onKeyDown.bind(this);
104 104
         this._onSubmit = this._onSubmit.bind(this);
105
+        this._renderFooter = this._renderFooter.bind(this);
105 106
         this._setDialogElement = this._setDialogElement.bind(this);
106
-
107
-        this._Footer = this._createFooterConstructor(props);
108
-    }
109
-
110
-    /**
111
-     * React Component method that executes before the component is updated.
112
-     *
113
-     * @inheritdoc
114
-     * @param {Object} nextProps - The next properties, before the update.
115
-     * @returns {void}
116
-     */
117
-    componentWillUpdate(nextProps) {
118
-        // If button states have changed, update the Footer constructor function
119
-        // so buttons of the proper state are rendered.
120
-        if (nextProps.okDisabled !== this.props.okDisabled
121
-                || nextProps.cancelDisabled !== this.props.cancelDisabled
122
-                || nextProps.submitDisabled !== this.props.submitDisabled) {
123
-            this._Footer = this._createFooterConstructor(nextProps);
124
-        }
125 107
     }
126 108
 
127 109
     /**
@@ -142,7 +124,7 @@ class StatelessDialog extends Component<Props> {
142 124
         return (
143 125
             <Modal
144 126
                 autoFocus = { true }
145
-                footer = { this._Footer }
127
+                footer = { this._renderFooter }
146 128
                 heading = { titleString || t(titleKey) }
147 129
                 i18n = { this.props.i18n }
148 130
                 onClose = { this._onDialogDismissed }
@@ -174,41 +156,38 @@ class StatelessDialog extends Component<Props> {
174 156
         );
175 157
     }
176 158
 
177
-    _onCancel: () => Function;
159
+    _renderFooter: () => React$Node;
178 160
 
179 161
     /**
180
-     * Returns a functional component to be used for the modal footer.
162
+     * Returns a ReactElement to display buttons for closing the modal.
181 163
      *
182
-     * @param {Object} options - The configuration for how the buttons in the
183
-     * footer should display. Essentially {@code StatelessDialog} props should
184
-     * be passed in.
164
+     * @param {Object} propsFromModalFooter - The props passed in from the
165
+     * {@link ModalFooter} component.
185 166
      * @private
186 167
      * @returns {ReactElement}
187 168
      */
188
-    _createFooterConstructor(options) {
169
+    _renderFooter(propsFromModalFooter) {
189 170
         // Filter out falsy (null) values because {@code ButtonGroup} will error
190 171
         // if passed in anything but buttons with valid type props.
191 172
         const buttons = [
192
-            this._renderOKButton(options),
193
-            this._renderCancelButton(options)
173
+            this._renderOKButton(),
174
+            this._renderCancelButton()
194 175
         ].filter(Boolean);
195 176
 
196
-        return function Footer(modalFooterProps) {
197
-            return (
198
-                <ModalFooter showKeyline = { modalFooterProps.showKeyline } >
199
-                    {
200
-
201
-                        /**
202
-                         * Atlaskit has this empty span (JustifySim) so...
203
-                         */
204
-                    }
205
-                    <span />
206
-                    <ButtonGroup>
207
-                        { buttons }
208
-                    </ButtonGroup>
209
-                </ModalFooter>
210
-            );
211
-        };
177
+        return (
178
+            <ModalFooter showKeyline = { propsFromModalFooter.showKeyline } >
179
+                {
180
+
181
+                    /**
182
+                     * Atlaskit has this empty span (JustifySim) so...
183
+                     */
184
+                }
185
+                <span />
186
+                <ButtonGroup>
187
+                    { buttons }
188
+                </ButtonGroup>
189
+            </ModalFooter>
190
+        );
212 191
     }
213 192
 
214 193
     _onCancel: () => void;
@@ -257,21 +236,14 @@ class StatelessDialog extends Component<Props> {
257 236
     /**
258 237
      * Renders Cancel button.
259 238
      *
260
-     * @param {Object} options - The configuration for the Cancel button.
261
-     * @param {boolean} options.cancelDisabled - True if the cancel button
262
-     * should not be rendered.
263
-     * @param {string} options.cancelTitleKey - The translation key to use as
264
-     * text on the button.
265
-     * @param {boolean} options.isModal - True if the cancel button should not
266
-     * be rendered.
267 239
      * @private
268 240
      * @returns {ReactElement|null} The Cancel button if enabled and dialog is
269 241
      * not modal.
270 242
      */
271
-    _renderCancelButton(options = {}) {
272
-        if (options.cancelDisabled
273
-                || options.isModal
274
-                || options.hideCancelButton) {
243
+    _renderCancelButton() {
244
+        if (this.props.cancelDisabled
245
+            || this.props.isModal
246
+            || this.props.hideCancelButton) {
275 247
             return null;
276 248
         }
277 249
 
@@ -286,7 +258,7 @@ class StatelessDialog extends Component<Props> {
286 258
                 key = 'cancel'
287 259
                 onClick = { this._onCancel }
288 260
                 type = 'button'>
289
-                { t(options.cancelTitleKey || 'dialog.Cancel') }
261
+                { t(this.props.cancelTitleKey || 'dialog.Cancel') }
290 262
             </Button>
291 263
         );
292 264
     }
@@ -294,18 +266,11 @@ class StatelessDialog extends Component<Props> {
294 266
     /**
295 267
      * Renders OK button.
296 268
      *
297
-     * @param {Object} options - The configuration for the OK button.
298
-     * @param {boolean} options.okDisabled - True if the button should display
299
-     * as disabled and clicking should have no effect.
300
-     * @param {string} options.okTitleKey - The translation key to use as text
301
-     * on the button.
302
-     * @param {boolean} options.submitDisabled - True if the button should not
303
-     * be rendered.
304 269
      * @private
305 270
      * @returns {ReactElement|null} The OK button if enabled.
306 271
      */
307
-    _renderOKButton(options = {}) {
308
-        if (options.submitDisabled) {
272
+    _renderOKButton() {
273
+        if (this.props.submitDisabled) {
309 274
             return null;
310 275
         }
311 276
 
@@ -318,11 +283,11 @@ class StatelessDialog extends Component<Props> {
318 283
                 appearance = 'primary'
319 284
                 form = 'modal-dialog-form'
320 285
                 id = { OK_BUTTON_ID }
321
-                isDisabled = { options.okDisabled }
286
+                isDisabled = { this.props.okDisabled }
322 287
                 key = 'submit'
323 288
                 onClick = { this._onSubmit }
324 289
                 type = 'button'>
325
-                { t(options.okTitleKey || 'dialog.Ok') }
290
+                { t(this.props.okTitleKey || 'dialog.Ok') }
326 291
             </Button>
327 292
         );
328 293
     }

+ 11
- 4
react/features/base/label/components/CircularLabel.native.js Bestand weergeven

@@ -64,17 +64,24 @@ export default class CircularLabel extends AbstractCircularLabel<Props, State> {
64 64
         this.state = {
65 65
             pulseAnimation: new Animated.Value(0)
66 66
         };
67
+    }
67 68
 
68
-        this._maybeToggleAnimation({}, props);
69
+    /**
70
+     * Implements {@code Component#componentDidMount}.
71
+     *
72
+     * @inheritdoc
73
+     */
74
+    componentDidMount() {
75
+        this._maybeToggleAnimation({}, this.props);
69 76
     }
70 77
 
71 78
     /**
72
-     * Implements {@code Component#componentWillReceiveProps}.
79
+     * Implements {@code Component#componentDidUpdate}.
73 80
      *
74 81
      * @inheritdoc
75 82
      */
76
-    componentWillReceiveProps(newProps: Props) {
77
-        this._maybeToggleAnimation(this.props, newProps);
83
+    componentDidUpdate(prevProps: Props) {
84
+        this._maybeToggleAnimation(prevProps, this.props);
78 85
     }
79 86
 
80 87
     /**

+ 16
- 7
react/features/base/react/components/native/SideBar.js Bestand weergeven

@@ -1,6 +1,6 @@
1 1
 // @flow
2 2
 
3
-import React, { Component, type Node } from 'react';
3
+import React, { PureComponent, type Node } from 'react';
4 4
 import { Animated, TouchableWithoutFeedback, View } from 'react-native';
5 5
 
6 6
 import styles, { SIDEBAR_WIDTH } from './styles';
@@ -46,7 +46,18 @@ type State = {
46 46
 /**
47 47
  * A generic animated side bar to be used for left-side, hamburger-style menus.
48 48
  */
49
-export default class SideBar extends Component<Props, State> {
49
+export default class SideBar extends PureComponent<Props, State> {
50
+    /**
51
+     * Implements React's {@link Component#getDerivedStateFromProps()}.
52
+     *
53
+     * @inheritdoc
54
+     */
55
+    static getDerivedStateFromProps(props: Props, prevState: State) {
56
+        return {
57
+            showOverlay: props.show || prevState.showOverlay
58
+        };
59
+    }
60
+
50 61
     /**
51 62
      * Initializes a new {@code SideBar} instance.
52 63
      *
@@ -74,12 +85,12 @@ export default class SideBar extends Component<Props, State> {
74 85
     }
75 86
 
76 87
     /**
77
-     * Implements React's {@link Component#componentWillReceiveProps()}.
88
+     * Implements React's {@link Component#componentDidUpdate()}.
78 89
      *
79 90
      * @inheritdoc
80 91
      */
81
-    componentWillReceiveProps({ show }: Props) {
82
-        (show === this.props.show) || this._setShow(show);
92
+    componentDidUpdate() {
93
+        this._setShow(this.props.show);
83 94
     }
84 95
 
85 96
     /**
@@ -148,8 +159,6 @@ export default class SideBar extends Component<Props, State> {
148 159
      * @returns {void}
149 160
      */
150 161
     _setShow(show) {
151
-        show && this.setState({ showOverlay: true });
152
-
153 162
         Animated
154 163
             .timing(
155 164
                 /* value */ this.state.sliderAnimation,

+ 11
- 1
react/features/base/toolbox/components/AbstractButton.js Bestand weergeven

@@ -206,6 +206,16 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
206 206
         return buttonStyles;
207 207
     }
208 208
 
209
+    /**
210
+     * Get the tooltip to display when hovering over the button.
211
+     *
212
+     * @private
213
+     * @returns {string}
214
+     */
215
+    _getTooltip() {
216
+        return this.tooltip || '';
217
+    }
218
+
209 219
     /**
210 220
      * Helper function to be implemented by subclasses, which must return a
211 221
      * boolean value indicating if this button is disabled or not.
@@ -258,7 +268,7 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
258 268
             iconName: this._getIconName(),
259 269
             label: this._getLabel(),
260 270
             styles: this._getStyles(),
261
-            tooltip: this.tooltip
271
+            tooltip: this._getTooltip()
262 272
         };
263 273
 
264 274
         return (

+ 4
- 12
react/features/deep-linking/components/DeepLinkingMobilePage.web.js Bestand weergeven

@@ -81,23 +81,15 @@ class DeepLinkingMobilePage extends Component<Props, State> {
81 81
     constructor(props: Props) {
82 82
         super(props);
83 83
 
84
+        this.state = {
85
+            joinURL: generateDeepLinkingURL()
86
+        };
87
+
84 88
         // Bind event handlers so they are only bound once per instance.
85 89
         this._onDownloadApp = this._onDownloadApp.bind(this);
86 90
         this._onOpenApp = this._onOpenApp.bind(this);
87 91
     }
88 92
 
89
-    /**
90
-     * Initializes the text and URL of the `Start a conference` / `Join the
91
-     * conversation` button which takes the user to the mobile app.
92
-     *
93
-     * @inheritdoc
94
-     */
95
-    componentWillMount() {
96
-        this.setState({
97
-            joinURL: generateDeepLinkingURL()
98
-        });
99
-    }
100
-
101 93
     /**
102 94
      * Implements the Component's componentDidMount method.
103 95
      *

+ 27
- 39
react/features/desktop-picker/components/DesktopPicker.js Bestand weergeven

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import Tabs from '@atlaskit/tabs';
4
-import React, { Component } from 'react';
4
+import React, { PureComponent } from 'react';
5 5
 import { connect } from 'react-redux';
6 6
 
7 7
 import { Dialog, hideDialog } from '../../base/dialog';
@@ -94,12 +94,36 @@ type State = {
94 94
     types: Array<string>
95 95
 };
96 96
 
97
+
97 98
 /**
98 99
  * React component for DesktopPicker.
99 100
  *
100 101
  * @extends Component
101 102
  */
102
-class DesktopPicker extends Component<Props, State> {
103
+class DesktopPicker extends PureComponent<Props, State> {
104
+    /**
105
+     * Implements React's {@link Component#getDerivedStateFromProps()}.
106
+     *
107
+     * @inheritdoc
108
+     */
109
+    static getDerivedStateFromProps(props) {
110
+        return {
111
+            types: DesktopPicker._getValidTypes(props.desktopSharingSources)
112
+        };
113
+    }
114
+
115
+    /**
116
+     * Extracts only the valid types from the passed {@code types}.
117
+     *
118
+     * @param {Array<string>} types - The types to filter.
119
+     * @private
120
+     * @returns {Array<string>} The filtered types.
121
+     */
122
+    static _getValidTypes(types = []) {
123
+        return types.filter(
124
+            type => VALID_TYPES.includes(type));
125
+    }
126
+
103 127
     _poller = null;
104 128
 
105 129
     state = {
@@ -133,7 +157,7 @@ class DesktopPicker extends Component<Props, State> {
133 157
         this._updateSources = this._updateSources.bind(this);
134 158
 
135 159
         this.state.types
136
-            = this._getValidTypes(this.props.desktopSharingSources);
160
+            = DesktopPicker._getValidTypes(this.props.desktopSharingSources);
137 161
     }
138 162
 
139 163
     /**
@@ -146,31 +170,6 @@ class DesktopPicker extends Component<Props, State> {
146 170
         this._startPolling();
147 171
     }
148 172
 
149
-    /**
150
-     * Notifies this mounted React Component that it will receive new props.
151
-     * Sets a default selected source if one is not already set.
152
-     *
153
-     * @inheritdoc
154
-     * @param {Object} nextProps - The read-only React Component props that this
155
-     * instance will receive.
156
-     * @returns {void}
157
-     */
158
-    componentWillReceiveProps(nextProps: Props) {
159
-        const { desktopSharingSources } = nextProps;
160
-
161
-        /**
162
-         * Do only reference check in order to not calculate the types on every
163
-         * update. This is enough for our use case and we don't need value
164
-         * checking because if the value is the same we won't change the
165
-         * reference for the desktopSharingSources array.
166
-         */
167
-        if (desktopSharingSources !== this.props.desktopSharingSources) {
168
-            this.setState({
169
-                types: this._getValidTypes(desktopSharingSources)
170
-            });
171
-        }
172
-    }
173
-
174 173
     /**
175 174
      * Clean up component and DesktopCapturerSource store state.
176 175
      *
@@ -241,17 +240,6 @@ class DesktopPicker extends Component<Props, State> {
241 240
         return selectedSource;
242 241
     }
243 242
 
244
-    /**
245
-     * Extracts only the valid types from the passed {@code types}.
246
-     *
247
-     * @param {Array<string>} types - The types to filter.
248
-     * @returns {Array<string>} The filtered types.
249
-     */
250
-    _getValidTypes(types = []) {
251
-        return types.filter(
252
-            type => VALID_TYPES.includes(type));
253
-    }
254
-
255 243
     _onCloseModal: (?string, string) => void;
256 244
 
257 245
     /**

+ 3
- 3
react/features/device-selection/components/AudioInputPreview.js Bestand weergeven

@@ -63,9 +63,9 @@ class AudioInputPreview extends Component<Props, State> {
63 63
      * @inheritdoc
64 64
      * @returns {void}
65 65
      */
66
-    componentWillReceiveProps(nextProps: Props) {
67
-        if (nextProps.track !== this.props.track) {
68
-            this._listenForAudioUpdates(nextProps.track);
66
+    componentDidUpdate(prevProps: Props) {
67
+        if (prevProps.track !== this.props.track) {
68
+            this._listenForAudioUpdates(this.props.track);
69 69
             this._updateAudioLevel(0);
70 70
         }
71 71
     }

+ 8
- 17
react/features/device-selection/components/DeviceSelection.js Bestand weergeven

@@ -151,7 +151,8 @@ class DeviceSelection extends AbstractDialogTab<Props, State> {
151 151
     }
152 152
 
153 153
     /**
154
-     * Checks if audio / video permissions were granted.
154
+     * Checks if audio / video permissions were granted. Updates audio input and
155
+     * video input previews.
155 156
      *
156 157
      * @param {Object} prevProps - Previous props this component received.
157 158
      * @param {Object} prevState - Previous state this component had.
@@ -174,25 +175,15 @@ class DeviceSelection extends AbstractDialogTab<Props, State> {
174 175
                 });
175 176
             });
176 177
         }
177
-    }
178
-
179
-    /**
180
-     * Updates audio input and video input previews.
181
-     *
182
-     * @inheritdoc
183
-     * @param {Object} nextProps - The read-only props which this Component will
184
-     * receive.
185
-     * @returns {void}
186
-     */
187
-    componentWillReceiveProps(nextProps: Object) {
188
-        const { selectedAudioInputId, selectedVideoInputId } = this.props;
189 178
 
190
-        if (selectedAudioInputId !== nextProps.selectedAudioInputId) {
191
-            this._createAudioInputTrack(nextProps.selectedAudioInputId);
179
+        if (prevProps.selectedAudioInputId
180
+            !== this.props.selectedAudioInputId) {
181
+            this._createAudioInputTrack(this.props.selectedAudioInputId);
192 182
         }
193 183
 
194
-        if (selectedVideoInputId !== nextProps.selectedVideoInputId) {
195
-            this._createVideoInputTrack(nextProps.selectedVideoInputId);
184
+        if (prevProps.selectedVideoInputId
185
+            !== this.props.selectedVideoInputId) {
186
+            this._createVideoInputTrack(this.props.selectedVideoInputId);
196 187
         }
197 188
     }
198 189
 

+ 24
- 34
react/features/invite/components/InfoDialogButton.web.js Bestand weergeven

@@ -70,6 +70,12 @@ type Props = {
70 70
  */
71 71
 type State = {
72 72
 
73
+    /**
74
+     * Cache the conference connection state to derive when transitioning from
75
+     * not joined to join, in order to auto-show the InfoDialog.
76
+     */
77
+    hasConnectedToConference: boolean,
78
+
73 79
     /**
74 80
      * Whether or not {@code InfoDialog} should be visible.
75 81
      */
@@ -83,6 +89,23 @@ type State = {
83 89
  * @extends Component
84 90
  */
85 91
 class InfoDialogButton extends Component<Props, State> {
92
+    /**
93
+     * Implements React's {@link Component#getDerivedStateFromProps()}.
94
+     *
95
+     * @inheritdoc
96
+     */
97
+    static getDerivedStateFromProps(props, state) {
98
+        return {
99
+            hasConnectedToConference: props._isConferenceJoined,
100
+            showDialog: (props._toolboxVisible && state.showDialog)
101
+                || (!state.hasConnectedToConference
102
+                    && props._isConferenceJoined
103
+                    && props._participantCount < 2
104
+                    && props._toolboxVisible
105
+                    && !props._disableAutoShow)
106
+        };
107
+    }
108
+
86 109
     /**
87 110
      * Initializes new {@code InfoDialogButton} instance.
88 111
      *
@@ -92,6 +115,7 @@ class InfoDialogButton extends Component<Props, State> {
92 115
         super(props);
93 116
 
94 117
         this.state = {
118
+            hasConnectedToConference: props._isConferenceJoined,
95 119
             showDialog: false
96 120
         };
97 121
 
@@ -111,22 +135,6 @@ class InfoDialogButton extends Component<Props, State> {
111 135
         }
112 136
     }
113 137
 
114
-    /**
115
-     * Update the visibility of the {@code InfoDialog}.
116
-     *
117
-     * @inheritdoc
118
-     */
119
-    componentWillReceiveProps(nextProps) {
120
-        // Ensure the dialog is closed when the toolbox becomes hidden.
121
-        if (this.state.showDialog && !nextProps._toolboxVisible) {
122
-            this._onDialogClose();
123
-
124
-            return;
125
-        }
126
-
127
-        this._maybeAutoShowDialog(nextProps);
128
-    }
129
-
130 138
     /**
131 139
      * Implements React's {@link Component#render()}.
132 140
      *
@@ -159,24 +167,6 @@ class InfoDialogButton extends Component<Props, State> {
159 167
         );
160 168
     }
161 169
 
162
-    /**
163
-     * Invoked to trigger display of the {@code InfoDialog} if certain
164
-     * conditions are met.
165
-     *
166
-     * @param {Object} nextProps - The future properties of this component.
167
-     * @private
168
-     * @returns {void}
169
-     */
170
-    _maybeAutoShowDialog(nextProps) {
171
-        if (!this.props._isConferenceJoined
172
-            && nextProps._isConferenceJoined
173
-            && nextProps._participantCount < 2
174
-            && nextProps._toolboxVisible
175
-            && !nextProps._disableAutoShow) {
176
-            this.setState({ showDialog: true });
177
-        }
178
-    }
179
-
180 170
     _onDialogClose: () => void;
181 171
 
182 172
     /**

+ 22
- 22
react/features/invite/components/info-dialog/InfoDialog.web.js Bestand weergeven

@@ -112,6 +112,28 @@ type State = {
112 112
 class InfoDialog extends Component<Props, State> {
113 113
     _copyElement: ?Object;
114 114
 
115
+    /**
116
+     * Implements React's {@link Component#getDerivedStateFromProps()}.
117
+     *
118
+     * @inheritdoc
119
+     */
120
+    static getDerivedStateFromProps(props, state) {
121
+        let phoneNumber = state.phoneNumber;
122
+
123
+        if (!state.phoneNumber && props.dialIn.numbers) {
124
+            const { defaultCountry, numbers } = props.dialIn;
125
+
126
+            phoneNumber = _getDefaultPhoneNumber(numbers, defaultCountry);
127
+        }
128
+
129
+        return {
130
+            // Exit edit mode when a password is set locally or remotely.
131
+            passwordEditEnabled: state.passwordEditEnabled && props._password
132
+                ? false : state.passwordEditEnabled,
133
+            phoneNumber
134
+        };
135
+    }
136
+
115 137
     /**
116 138
      * {@code InfoDialog} component's local state.
117 139
      *
@@ -162,28 +184,6 @@ class InfoDialog extends Component<Props, State> {
162 184
         this._setCopyElement = this._setCopyElement.bind(this);
163 185
     }
164 186
 
165
-    /**
166
-     * Implements React's {@link Component#componentWillReceiveProps()}. Invoked
167
-     * before this mounted component receives new props.
168
-     *
169
-     * @inheritdoc
170
-     * @param {Props} nextProps - New props component will receive.
171
-     */
172
-    componentWillReceiveProps(nextProps) {
173
-        if (!this.props._password && nextProps._password) {
174
-            this.setState({ passwordEditEnabled: false });
175
-        }
176
-
177
-        if (!this.state.phoneNumber && nextProps.dialIn.numbers) {
178
-            const { defaultCountry, numbers } = nextProps.dialIn;
179
-
180
-            this.setState({
181
-                phoneNumber:
182
-                    _getDefaultPhoneNumber(numbers, defaultCountry)
183
-            });
184
-        }
185
-    }
186
-
187 187
     /**
188 188
      * Implements React's {@link Component#render()}.
189 189
      *

+ 11
- 14
react/features/invite/components/info-dialog/PasswordForm.web.js Bestand weergeven

@@ -55,6 +55,17 @@ type State = {
55 55
  * @extends Component
56 56
  */
57 57
 class PasswordForm extends Component<Props, State> {
58
+    /**
59
+     * Implements React's {@link Component#getDerivedStateFromProps()}.
60
+     *
61
+     * @inheritdoc
62
+     */
63
+    static getDerivedStateFromProps(props, state) {
64
+        return {
65
+            enteredPassword: props.editEnabled ? state.enteredPassword : ''
66
+        };
67
+    }
68
+
58 69
     state = {
59 70
         enteredPassword: ''
60 71
     };
@@ -74,19 +85,6 @@ class PasswordForm extends Component<Props, State> {
74 85
         this._onPasswordSubmit = this._onPasswordSubmit.bind(this);
75 86
     }
76 87
 
77
-    /**
78
-     * Implements React's {@link Component#componentWillReceiveProps()}. Invoked
79
-     * before this mounted component receives new props.
80
-     *
81
-     * @inheritdoc
82
-     * @param {Props} nextProps - New props component will receive.
83
-     */
84
-    componentWillReceiveProps(nextProps: Props) {
85
-        if (this.props.editEnabled && !nextProps.editEnabled) {
86
-            this.setState({ enteredPassword: '' });
87
-        }
88
-    }
89
-
90 88
     /**
91 89
      * Implements React's {@link Component#render()}.
92 90
      *
@@ -182,5 +180,4 @@ class PasswordForm extends Component<Props, State> {
182 180
     }
183 181
 }
184 182
 
185
-
186 183
 export default translate(PasswordForm);

+ 13
- 16
react/features/large-video/components/Labels.web.js Bestand weergeven

@@ -32,6 +32,19 @@ type State = {
32 32
  * @extends Component
33 33
  */
34 34
 class Labels extends AbstractLabels<Props, State> {
35
+    /**
36
+     * Updates the state for whether or not the filmstrip is transitioning to
37
+     * a displayed state.
38
+     *
39
+     * @inheritdoc
40
+     */
41
+    static getDerivedStateFromProps(props, prevState) {
42
+        return {
43
+            filmstripBecomingVisible: !prevState.filmstripBecomingVisible
44
+                && props._filmstripVisible
45
+        };
46
+    }
47
+
35 48
     /**
36 49
      * Initializes a new {@code Labels} instance.
37 50
      *
@@ -46,22 +59,6 @@ class Labels extends AbstractLabels<Props, State> {
46 59
         };
47 60
     }
48 61
 
49
-    /**
50
-     * Updates the state for whether or not the filmstrip is being toggled to
51
-     * display after having being hidden.
52
-     *
53
-     * @inheritdoc
54
-     * @param {Object} nextProps - The read-only props which this Component will
55
-     * receive.
56
-     * @returns {void}
57
-     */
58
-    componentWillReceiveProps(nextProps) {
59
-        this.setState({
60
-            filmstripBecomingVisible: nextProps._filmstripVisible
61
-                && !this.props._filmstripVisible
62
-        });
63
-    }
64
-
65 62
     /**
66 63
      * Implements React's {@link Component#render()}.
67 64
      *

+ 4
- 6
react/features/large-video/components/LargeVideoBackground.web.js Bestand weergeven

@@ -117,17 +117,15 @@ export class LargeVideoBackground extends Component<Props> {
117 117
      * Starts or stops the interval to update the image displayed in the canvas.
118 118
      *
119 119
      * @inheritdoc
120
-     * @param {Object} nextProps - The read-only React {@code Component} props
121
-     * with which the new instance is to be initialized.
122 120
      */
123
-    componentWillReceiveProps(nextProps: Props) {
124
-        if (this.props.hidden && !nextProps.hidden) {
121
+    componentDidUpdate(prevProps: Props) {
122
+        if (prevProps.hidden && !this.props.hidden) {
125 123
             this._clearCanvas();
126 124
             this._setUpdateCanvasInterval();
127 125
         }
128 126
 
129
-        if ((!this.props.hidden && nextProps.hidden)
130
-            || !nextProps.videoElement) {
127
+        if ((!prevProps.hidden && this.props.hidden)
128
+            || !this.props.videoElement) {
131 129
             this._clearCanvas();
132 130
             this._clearUpdateCanvasInterval();
133 131
         }

+ 2
- 2
react/features/mobile/audio-mode/components/AudioRoutePickerDialog.js Bestand weergeven

@@ -109,7 +109,7 @@ class AudioRoutePickerDialog extends Component<Props, State> {
109 109
     state = {
110 110
         /**
111 111
          * Available audio devices, it will be set in
112
-         * {@link #componentWillMount()}.
112
+         * {@link #componentDidMount()}.
113 113
          */
114 114
         devices: []
115 115
     };
@@ -132,7 +132,7 @@ class AudioRoutePickerDialog extends Component<Props, State> {
132 132
      *
133 133
      * @inheritdoc
134 134
      */
135
-    componentWillMount() {
135
+    componentDidMount() {
136 136
         AudioMode.getAudioDevices().then(({ devices, selected }) => {
137 137
             const audioDevices = [];
138 138
 

+ 15
- 8
react/features/recording/components/AbstractRecordingLabel.js Bestand weergeven

@@ -54,6 +54,18 @@ const STALE_TIMEOUT = 10 * 1000;
54 54
  */
55 55
 export default class AbstractRecordingLabel
56 56
     extends Component<Props, State> {
57
+    /**
58
+     * Implements {@code Component#getDerivedStateFromProps}.
59
+     *
60
+     * @inheritdoc
61
+     */
62
+    static getDerivedStateFromProps(props: Props, prevState: State) {
63
+        return {
64
+            staleLabel: props._status !== JitsiRecordingConstants.status.OFF
65
+                && prevState.staleLabel ? false : prevState.staleLabel
66
+        };
67
+    }
68
+
57 69
     /**
58 70
      * Initializes a new {@code AbstractRecordingLabel} component.
59 71
      *
@@ -70,12 +82,12 @@ export default class AbstractRecordingLabel
70 82
     }
71 83
 
72 84
     /**
73
-     * Implements {@code Component#componentWillReceiveProps}.
85
+     * Implements {@code Component#componentDidUpdate}.
74 86
      *
75 87
      * @inheritdoc
76 88
      */
77
-    componentWillReceiveProps(newProps: Props) {
78
-        this._updateStaleStatus(this.props, newProps);
89
+    componentDidUpdate(prevProps: Props) {
90
+        this._updateStaleStatus(prevProps, this.props);
79 91
     }
80 92
 
81 93
     /**
@@ -137,13 +149,8 @@ export default class AbstractRecordingLabel
137 149
                     }
138 150
                 }, STALE_TIMEOUT);
139 151
             }
140
-        } else if (this.state.staleLabel) {
141
-            this.setState({
142
-                staleLabel: false
143
-            });
144 152
         }
145 153
     }
146
-
147 154
 }
148 155
 
149 156
 /**

+ 1
- 30
react/features/recording/components/LiveStream/AbstractStreamKeyForm.js Bestand weergeven

@@ -33,24 +33,13 @@ export type Props = {
33 33
     value: string
34 34
 };
35 35
 
36
-/**
37
- * The state of the component.
38
- */
39
-type State = {
40
-
41
-    /**
42
-     * The value entered in the field.
43
-     */
44
-    value: string
45
-}
46
-
47 36
 /**
48 37
  * An abstract React Component for entering a key for starting a YouTube live
49 38
  * stream.
50 39
  *
51 40
  * @extends Component
52 41
  */
53
-export default class AbstractStreamKeyForm extends Component<Props, State> {
42
+export default class AbstractStreamKeyForm extends Component<Props> {
54 43
     helpURL: string;
55 44
 
56 45
     /**
@@ -61,10 +50,6 @@ export default class AbstractStreamKeyForm extends Component<Props, State> {
61 50
     constructor(props: Props) {
62 51
         super(props);
63 52
 
64
-        this.state = {
65
-            value: props.value
66
-        };
67
-
68 53
         this.helpURL = (typeof interfaceConfig !== 'undefined'
69 54
             && interfaceConfig.LIVE_STREAMING_HELP_LINK)
70 55
             || LIVE_STREAMING_HELP_LINK;
@@ -73,17 +58,6 @@ export default class AbstractStreamKeyForm extends Component<Props, State> {
73 58
         this._onInputChange = this._onInputChange.bind(this);
74 59
     }
75 60
 
76
-    /**
77
-     * Implements {@code Component}'s componentWillReceiveProps.
78
-     *
79
-     * @inheritdoc
80
-     */
81
-    componentWillReceiveProps(newProps: Props) {
82
-        this.setState({
83
-            value: newProps.value
84
-        });
85
-    }
86
-
87 61
     _onInputChange: Object => void
88 62
 
89 63
     /**
@@ -99,9 +73,6 @@ export default class AbstractStreamKeyForm extends Component<Props, State> {
99 73
     _onInputChange(change) {
100 74
         const value = typeof change === 'object' ? change.target.value : change;
101 75
 
102
-        this.setState({
103
-            value
104
-        });
105 76
         this.props.onChange(value);
106 77
     }
107 78
 }

+ 1
- 1
react/features/recording/components/LiveStream/native/StreamKeyForm.js Bestand weergeven

@@ -50,7 +50,7 @@ class StreamKeyForm extends AbstractStreamKeyForm {
50 50
                     onChangeText = { this._onInputChange }
51 51
                     placeholder = { t('liveStreaming.enterStreamKey') }
52 52
                     style = { styles.streamKeyInput }
53
-                    value = { this.state.value } />
53
+                    value = { this.props.value } />
54 54
                 <TouchableOpacity
55 55
                     onPress = { this._onOpenHelp }
56 56
                     style = { styles.streamKeyHelp } >

+ 10
- 20
react/features/recording/components/LiveStream/web/LiveStreamButton.js Bestand weergeven

@@ -37,26 +37,6 @@ class LiveStreamButton extends AbstractLiveStreamButton<Props> {
37 37
     iconName = 'icon-public';
38 38
     toggledIconName = 'icon-public';
39 39
 
40
-    /**
41
-     * Constructor of the component.
42
-     *
43
-     * @inheritdoc
44
-     */
45
-    constructor(props: Props) {
46
-        super(props);
47
-
48
-        this.tooltip = props._liveStreamDisabledTooltipKey;
49
-    }
50
-
51
-    /**
52
-     * Implements {@code Component}'s componentWillReceiveProps.
53
-     *
54
-     * @inheritdoc
55
-     */
56
-    componentWillReceiveProps(newProps: Props) {
57
-        this.tooltip = newProps._liveStreamDisabledTooltipKey;
58
-    }
59
-
60 40
     /**
61 41
      * Helper function to be implemented by subclasses, which returns
62 42
      * a React Element to display (a beta tag) at the end of the button.
@@ -76,6 +56,16 @@ class LiveStreamButton extends AbstractLiveStreamButton<Props> {
76 56
         );
77 57
     }
78 58
 
59
+    /**
60
+     * Returns the tooltip that should be displayed when the button is disabled.
61
+     *
62
+     * @private
63
+     * @returns {string}
64
+     */
65
+    _getTooltip() {
66
+        return this.props._liveStreamDisabledTooltipKey || '';
67
+    }
68
+
79 69
     /**
80 70
      * Helper function to be implemented by subclasses, which must return a
81 71
      * boolean value indicating if this button is disabled or not.

+ 1
- 1
react/features/recording/components/LiveStream/web/StreamKeyForm.js Bestand weergeven

@@ -51,7 +51,7 @@ class StreamKeyForm extends AbstractStreamKeyForm {
51 51
                     placeholder = { t('liveStreaming.enterStreamKey') }
52 52
                     shouldFitContainer = { true }
53 53
                     type = 'text'
54
-                    value = { this.state.value } />
54
+                    value = { this.props.value } />
55 55
                 { this.helpURL
56 56
                     ? <div className = 'form-footer'>
57 57
                         <a

+ 5
- 15
react/features/recording/components/Recording/web/RecordButton.js Bestand weergeven

@@ -36,23 +36,13 @@ class RecordButton extends AbstractRecordButton<Props> {
36 36
     toggledIconName = 'icon-camera-take-picture';
37 37
 
38 38
     /**
39
-     * Constructor of the component.
39
+     * Returns the tooltip that should be displayed when the button is disabled.
40 40
      *
41
-     * @inheritdoc
41
+     * @private
42
+     * @returns {string}
42 43
      */
43
-    constructor(props: Props) {
44
-        super(props);
45
-
46
-        this.tooltip = props._fileRecordingsDisabledTooltipKey;
47
-    }
48
-
49
-    /**
50
-     * Implements {@code Component}'s componentWillReceiveProps.
51
-     *
52
-     * @inheritdoc
53
-     */
54
-    componentWillReceiveProps(newProps: Props) {
55
-        this.tooltip = newProps._fileRecordingsDisabledTooltipKey;
44
+    _getTooltip() {
45
+        return this.tooltip || '';
56 46
     }
57 47
 
58 48
     /**

+ 8
- 11
react/features/speaker-stats/components/SpeakerStats.js Bestand weergeven

@@ -12,7 +12,7 @@ import SpeakerStatsLabels from './SpeakerStatsLabels';
12 12
 declare var interfaceConfig: Object;
13 13
 
14 14
 /**
15
- * The type of the React {@code Component} props of {@link SpeakerStats}
15
+ * The type of the React {@code Component} props of {@link SpeakerStats}.
16 16
  */
17 17
 type Props = {
18 18
 
@@ -33,7 +33,7 @@ type Props = {
33 33
 };
34 34
 
35 35
 /**
36
- * The type of the React {@code Component} state of {@link SpeakerStats}
36
+ * The type of the React {@code Component} state of {@link SpeakerStats}.
37 37
  */
38 38
 type State = {
39 39
 
@@ -49,10 +49,6 @@ type State = {
49 49
  * @extends Component
50 50
  */
51 51
 class SpeakerStats extends Component<Props, State> {
52
-    state = {
53
-        stats: {}
54
-    };
55
-
56 52
     _updateInterval: IntervalID;
57 53
 
58 54
     /**
@@ -64,19 +60,20 @@ class SpeakerStats extends Component<Props, State> {
64 60
     constructor(props) {
65 61
         super(props);
66 62
 
63
+        this.state = {
64
+            stats: this.props.conference.getSpeakerStats()
65
+        };
66
+
67 67
         // Bind event handlers so they are only bound once per instance.
68 68
         this._updateStats = this._updateStats.bind(this);
69 69
     }
70 70
 
71 71
     /**
72
-     * Immediately request for updated speaker stats and begin
73
-     * polling for speaker stats updates.
72
+     * Begin polling for speaker stats updates.
74 73
      *
75 74
      * @inheritdoc
76
-     * @returns {void}
77 75
      */
78
-    componentWillMount() {
79
-        this._updateStats();
76
+    componentDidMount() {
80 77
         this._updateInterval = setInterval(this._updateStats, 1000);
81 78
     }
82 79
 

+ 5
- 5
react/features/toolbox/components/web/Toolbox.js Bestand weergeven

@@ -280,15 +280,15 @@ class Toolbox extends Component<Props> {
280 280
      *
281 281
      * @inheritdoc
282 282
      */
283
-    componentWillReceiveProps(nextProps) {
283
+    componentDidUpdate(prevProps) {
284 284
         // Ensure the dialog is closed when the toolbox becomes hidden.
285
-        if (this.props._overflowMenuVisible && !nextProps._visible) {
285
+        if (prevProps._overflowMenuVisible && !this.props._visible) {
286 286
             this._onSetOverflowVisible(false);
287 287
         }
288 288
 
289
-        if (this.props._overflowMenuVisible
290
-            && !this.props._dialog
291
-            && nextProps._dialog) {
289
+        if (prevProps._overflowMenuVisible
290
+            && !prevProps._dialog
291
+            && this.props._dialog) {
292 292
             this._onSetOverflowVisible(false);
293 293
             this.props.dispatch(setToolbarHovered(false));
294 294
         }

+ 14
- 14
react/features/welcome/components/AbstractWelcomePage.js Bestand weergeven

@@ -37,6 +37,17 @@ type Props = {
37 37
 export class AbstractWelcomePage extends Component<Props, *> {
38 38
     _mounted: ?boolean;
39 39
 
40
+    /**
41
+     * Implements React's {@link Component#getDerivedStateFromProps()}.
42
+     *
43
+     * @inheritdoc
44
+     */
45
+    static getDerivedStateFromProps(props: Props, state: Object) {
46
+        return {
47
+            room: props._room || state.room
48
+        };
49
+    }
50
+
40 51
     /**
41 52
      * Save room name into component's local state.
42 53
      *
@@ -77,26 +88,15 @@ export class AbstractWelcomePage extends Component<Props, *> {
77 88
     }
78 89
 
79 90
     /**
80
-     * Implements React's {@link Component#componentWillMount()}. Invoked
81
-     * immediately before mounting occurs.
91
+     * Implements React's {@link Component#componentDidMount()}. Invoked
92
+     * immediately after mounting occurs.
82 93
      *
83 94
      * @inheritdoc
84 95
      */
85
-    componentWillMount() {
96
+    componentDidMount() {
86 97
         this._mounted = true;
87 98
     }
88 99
 
89
-    /**
90
-     * Implements React's {@link Component#componentWillReceiveProps()}. Invoked
91
-     * before this mounted component receives new props.
92
-     *
93
-     * @inheritdoc
94
-     * @param {Props} nextProps - New props component will receive.
95
-     */
96
-    componentWillReceiveProps(nextProps: Props) {
97
-        this.setState({ room: nextProps._room });
98
-    }
99
-
100 100
     /**
101 101
      * Implements React's {@link Component#componentWillUnmount()}. Invoked
102 102
      * immediately before this component is unmounted and destroyed.

+ 1
- 1
react/features/welcome/components/BlankPage.native.js Bestand weergeven

@@ -29,7 +29,7 @@ class BlankPage extends Component<Props> {
29 29
      * @inheritdoc
30 30
      * @returns {void}
31 31
      */
32
-    componentWillMount() {
32
+    componentDidMount() {
33 33
         this.props.dispatch(destroyLocalTracks());
34 34
     }
35 35
 

+ 4
- 4
react/features/welcome/components/WelcomePage.native.js Bestand weergeven

@@ -57,15 +57,15 @@ class WelcomePage extends AbstractWelcomePage {
57 57
     }
58 58
 
59 59
     /**
60
-     * Implements React's {@link Component#componentWillMount()}. Invoked
61
-     * immediately before mounting occurs. Creates a local video track if none
60
+     * Implements React's {@link Component#componentDidMount()}. Invoked
61
+     * immediately after mounting occurs. Creates a local video track if none
62 62
      * is available and the camera permission was already granted.
63 63
      *
64 64
      * @inheritdoc
65 65
      * @returns {void}
66 66
      */
67
-    componentWillMount() {
68
-        super.componentWillMount();
67
+    componentDidMount() {
68
+        super.componentDidMount();
69 69
 
70 70
         const { dispatch } = this.props;
71 71
 

Laden…
Annuleren
Opslaan