Label and use UNSAFE_componentWillMount to minimize warnings

These TODO comments are expected to be fixed ASAP, but until that happens let's minimize the errors in the console for development.

For https://github.com/vector-im/riot-web/issues/12877

These all aren't using componentDidMount because they do something which causes application instability if componentDidMount were used. Much of these calls are expected to move into constructors once they are converted to real classes.
This commit is contained in:
Travis Ralston 2020-03-31 14:12:52 -06:00
parent 56dda3895c
commit 0a6f54da33
37 changed files with 58 additions and 22 deletions

View file

@ -42,7 +42,8 @@ export default createReactClass({
}; };
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() {
this._unmounted = false; this._unmounted = false;
this._passphrase1 = createRef(); this._passphrase1 = createRef();

View file

@ -54,7 +54,8 @@ export default createReactClass({
}; };
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() {
this._unmounted = false; this._unmounted = false;
this._file = createRef(); this._file = createRef();

View file

@ -87,7 +87,8 @@ export default createReactClass({
}; };
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() {
this._unmounted = false; this._unmounted = false;
this._authLogic = new InteractiveAuth({ this._authLogic = new InteractiveAuth({
authData: this.props.authData, authData: this.props.authData,

View file

@ -94,7 +94,8 @@ const LoggedInView = createReactClass({
this._loadResizerPreferences(); this._loadResizerPreferences();
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() {
// stash the MatrixClient in case we log out before we are unmounted // stash the MatrixClient in case we log out before we are unmounted
this._matrixClient = this.props.matrixClient; this._matrixClient = this.props.matrixClient;

View file

@ -168,7 +168,8 @@ export default createReactClass({
}; };
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() {
this.dispatcherRef = dis.register(this.onAction); this.dispatcherRef = dis.register(this.onAction);
this.context.on("Room", this.onRoom); this.context.on("Room", this.onRoom);
this.context.on("Room.timeline", this.onRoomTimeline); this.context.on("Room.timeline", this.onRoomTimeline);

View file

@ -156,9 +156,8 @@ export default createReactClass({
}; };
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
this._fillRequestWhileRunning = false; UNSAFE_componentWillMount: function() {
this._isFilling = false;
this._pendingFillRequests = {b: null, f: null}; this._pendingFillRequests = {b: null, f: null};
if (this.props.resizeNotifier) { if (this.props.resizeNotifier) {

View file

@ -53,6 +53,7 @@ export default createReactClass({
}; };
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._search = createRef(); this._search = createRef();
}, },

View file

@ -202,7 +202,8 @@ const TimelinePanel = createReactClass({
}; };
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() {
debuglog("TimelinePanel: mounting"); debuglog("TimelinePanel: mounting");
this.lastRRSentEventId = undefined; this.lastRRSentEventId = undefined;

View file

@ -46,7 +46,8 @@ export default createReactClass({
}; };
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() {
this._captchaWidgetId = null; this._captchaWidgetId = null;
this._recaptchaContainer = createRef(); this._recaptchaContainer = createRef();

View file

@ -238,6 +238,7 @@ export const TermsAuthEntry = createReactClass({
showContinue: PropTypes.bool, showContinue: PropTypes.bool,
}, },
// TODO: [REACT-WARNING] Move this to constructor
componentWillMount: function() { componentWillMount: function() {
// example stageParams: // example stageParams:
// //
@ -575,7 +576,8 @@ export const FallbackAuthEntry = createReactClass({
errorText: PropTypes.string, errorText: PropTypes.string,
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() {
// we have to make the user click a button, as browsers will block // we have to make the user click a button, as browsers will block
// the popup if we open it immediately. // the popup if we open it immediately.
this._popupWindow = null; this._popupWindow = null;

View file

@ -107,6 +107,7 @@ export default createReactClass({
}; };
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._textinput = createRef(); this._textinput = createRef();
}, },

View file

@ -86,7 +86,8 @@ export default createReactClass({
}; };
}, },
componentWillMount() { // TODO: [REACT-WARNING] Move this to constructor
UNSAFE_componentWillMount() {
this._matrixClient = MatrixClientPeg.get(); this._matrixClient = MatrixClientPeg.get();
}, },

View file

@ -62,6 +62,7 @@ export default createReactClass({
}; };
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._input_value = createRef(); this._input_value = createRef();
this._uiAuth = createRef(); this._uiAuth = createRef();

View file

@ -55,6 +55,7 @@ export default createReactClass({
}; };
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._field = createRef(); this._field = createRef();
}, },

View file

@ -116,7 +116,8 @@ export default class Dropdown extends React.Component {
}; };
} }
componentWillMount() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount() {
this._button = createRef(); this._button = createRef();
// Listen for all clicks on the document so we can close the // Listen for all clicks on the document so we can close the
// menu when the user clicks somewhere else // menu when the user clicks somewhere else

View file

@ -71,7 +71,8 @@ export default createReactClass({
} }
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() {
// we track value as an JS object field rather than in React state // we track value as an JS object field rather than in React state
// as React doesn't play nice with contentEditable. // as React doesn't play nice with contentEditable.
this.value = ''; this.value = '';

View file

@ -63,6 +63,7 @@ export default createReactClass({
}, },
componentWillMount: function() { componentWillMount: function() {
// TODO: [REACT-WARNING] Move this to class constructor
this._initStateFromProps(this.props); this._initStateFromProps(this.props);
}, },

View file

@ -35,6 +35,7 @@ export default createReactClass({
}; };
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._user_id_input = createRef(); this._user_id_input = createRef();
}, },

View file

@ -170,6 +170,7 @@ export default createReactClass({
return MatrixClientPeg.get().mxcUrlToHttp(content.url); return MatrixClientPeg.get().mxcUrlToHttp(content.url);
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._iframe = createRef(); this._iframe = createRef();
this._dummyLink = createRef(); this._dummyLink = createRef();

View file

@ -47,6 +47,7 @@ export default createReactClass({
maxImageHeight: PropTypes.number, maxImageHeight: PropTypes.number,
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._body = createRef(); this._body = createRef();
}, },

View file

@ -86,6 +86,7 @@ export default createReactClass({
return successful; return successful;
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._content = createRef(); this._content = createRef();
}, },

View file

@ -233,7 +233,8 @@ export default createReactClass({
contextType: MatrixClientContext, contextType: MatrixClientContext,
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() {
// don't do RR animations until we are mounted // don't do RR animations until we are mounted
this._suppressReadReceiptAnimation = true; this._suppressReadReceiptAnimation = true;
this._verifyEvent(this.props.mxEvent); this._verifyEvent(this.props.mxEvent);

View file

@ -43,7 +43,8 @@ export default createReactClass({
}; };
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() {
this.unmounted = false; this.unmounted = false;
MatrixClientPeg.get().getUrlPreview(this.props.link, this.props.mxEvent.getTs()).then((res)=>{ MatrixClientPeg.get().getUrlPreview(this.props.link, this.props.mxEvent.getTs()).then((res)=>{
if (this.unmounted) { if (this.unmounted) {

View file

@ -87,6 +87,7 @@ export default createReactClass({
}; };
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._avatar = createRef(); this._avatar = createRef();
}, },

View file

@ -54,6 +54,7 @@ export default createReactClass({
} }
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._topic = createRef(); this._topic = createRef();
}, },

View file

@ -58,6 +58,7 @@ export default createReactClass({
}; };
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._topic = createRef(); this._topic = createRef();
}, },

View file

@ -118,7 +118,8 @@ export default createReactClass({
}; };
}, },
componentWillMount: function() { // TODO: [REACT-WARNING] Replace component with real class, put this in the constructor.
UNSAFE_componentWillMount: function() {
this.mounted = false; this.mounted = false;
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();

View file

@ -224,6 +224,7 @@ export default createReactClass({
}); });
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._roomTile = createRef(); this._roomTile = createRef();
}, },

View file

@ -30,6 +30,7 @@ export default createReactClass({
}); });
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._search_term = createRef(); this._search_term = createRef();
}, },

View file

@ -331,7 +331,8 @@ export default class SendMessageComposer extends React.Component {
this._editorRef.getEditableRootNode().removeEventListener("paste", this._onPaste, true); this._editorRef.getEditableRootNode().removeEventListener("paste", this._onPaste, true);
} }
componentWillMount() { // TODO: [REACT-WARNING] Move this to constructor
UNSAFE_componentWillMount() {
const partCreator = new CommandPartCreator(this.props.room, this.context); const partCreator = new CommandPartCreator(this.props.room, this.context);
const parts = this._restoreStoredEditorState(partCreator) || []; const parts = this._restoreStoredEditorState(partCreator) || [];
this.model = new EditorModel(parts, partCreator); this.model = new EditorModel(parts, partCreator);

View file

@ -38,7 +38,8 @@ export default class AdvancedRoomSettingsTab extends React.Component {
}; };
} }
componentWillMount() { // TODO: [REACT-WARNING] Move this to constructor
UNSAFE_componentWillMount() {
// we handle lack of this object gracefully later, so don't worry about it failing here. // we handle lack of this object gracefully later, so don't worry about it failing here.
const room = MatrixClientPeg.get().getRoom(this.props.roomId); const room = MatrixClientPeg.get().getRoom(this.props.roomId);
room.getRecommendedVersion().then((v) => { room.getRecommendedVersion().then((v) => {

View file

@ -37,7 +37,8 @@ export default class NotificationsSettingsTab extends React.Component {
}; };
} }
componentWillMount() { // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount() {
Notifier.getSoundForRoom(this.props.roomId).then((soundData) => { Notifier.getSoundForRoom(this.props.roomId).then((soundData) => {
if (!soundData) { if (!soundData) {
return; return;

View file

@ -41,7 +41,8 @@ export default class SecurityRoomSettingsTab extends React.Component {
}; };
} }
async componentWillMount(): void { // TODO: [REACT-WARNING] Move this to constructor
async UNSAFE_componentWillMount(): void {
MatrixClientPeg.get().on("RoomState.events", this._onStateEvent); MatrixClientPeg.get().on("RoomState.events", this._onStateEvent);
const room = MatrixClientPeg.get().getRoom(this.props.roomId); const room = MatrixClientPeg.get().getRoom(this.props.roomId);

View file

@ -68,7 +68,8 @@ export default class GeneralUserSettingsTab extends React.Component {
this.dispatcherRef = dis.register(this._onAction); this.dispatcherRef = dis.register(this._onAction);
} }
async componentWillMount() { // TODO: [REACT-WARNING] Move this to constructor
async UNSAFE_componentWillMount() {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
const serverSupportsSeparateAddAndBind = await cli.doesServerSupportSeparateAddAndBind(); const serverSupportsSeparateAddAndBind = await cli.doesServerSupportSeparateAddAndBind();

View file

@ -57,6 +57,7 @@ export default createReactClass({
}; };
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._video = createRef(); this._video = createRef();
}, },

View file

@ -31,6 +31,7 @@ export default createReactClass({
onResize: PropTypes.func, onResize: PropTypes.func,
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount() { UNSAFE_componentWillMount() {
this._vid = createRef(); this._vid = createRef();
}, },

View file

@ -50,6 +50,7 @@ export default createReactClass({
onResize: PropTypes.func, onResize: PropTypes.func,
}, },
// TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
UNSAFE_componentWillMount: function() { UNSAFE_componentWillMount: function() {
this._local = createRef(); this._local = createRef();
this._remote = createRef(); this._remote = createRef();