From 47e5cfecf211e56046be53a24837e266b87e7730 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 1 Apr 2020 14:35:39 -0600 Subject: [PATCH] Silence usages of componentWillReceiveProps For https://github.com/vector-im/riot-web/issues/12877 --- src/components/structures/GroupView.js | 5 +++-- src/components/structures/RightPanel.js | 3 ++- src/components/structures/TimelinePanel.js | 3 ++- src/components/structures/auth/ForgotPassword.js | 3 ++- src/components/structures/auth/Login.js | 3 ++- src/components/structures/auth/Registration.js | 3 ++- src/components/views/auth/ServerConfig.js | 3 ++- src/components/views/avatars/BaseAvatar.js | 3 ++- src/components/views/avatars/MemberAvatar.js | 3 ++- src/components/views/avatars/RoomAvatar.js | 3 ++- src/components/views/dialogs/DevtoolsDialog.js | 3 ++- src/components/views/elements/AddressSelector.js | 3 ++- src/components/views/elements/AppTile.js | 3 ++- src/components/views/elements/Dropdown.js | 3 ++- src/components/views/elements/EditableText.js | 3 ++- src/components/views/elements/Flair.js | 3 ++- src/components/views/elements/Pill.js | 5 +++-- src/components/views/elements/PowerSelector.js | 3 ++- src/components/views/elements/SyntaxHighlight.js | 1 - src/components/views/groups/GroupMemberInfo.js | 3 ++- src/components/views/groups/GroupRoomInfo.js | 3 ++- src/components/views/rooms/AppsDrawer.js | 3 ++- src/components/views/rooms/EventTile.js | 3 ++- src/components/views/rooms/MemberInfo.js | 3 ++- src/components/views/rooms/RoomTile.js | 3 ++- src/components/views/settings/ChangeAvatar.js | 3 ++- src/components/views/settings/discovery/EmailAddresses.js | 3 ++- src/components/views/settings/discovery/PhoneNumbers.js | 3 ++- 28 files changed, 56 insertions(+), 30 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 73a8879f6d..3b32e5c907 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -450,8 +450,9 @@ export default createReactClass({ } }, - componentWillReceiveProps: function(newProps) { - if (this.props.groupId != newProps.groupId) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(newProps) { + if (this.props.groupId !== newProps.groupId) { this.setState({ summary: null, error: null, diff --git a/src/components/structures/RightPanel.js b/src/components/structures/RightPanel.js index 5e556419cc..856a3764a1 100644 --- a/src/components/structures/RightPanel.js +++ b/src/components/structures/RightPanel.js @@ -123,7 +123,8 @@ export default class RightPanel extends React.Component { this._unregisterGroupStore(this.props.groupId); } - componentWillReceiveProps(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(newProps) { if (newProps.groupId !== this.props.groupId) { this._unregisterGroupStore(this.props.groupId); this._initGroupStore(newProps.groupId); diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 1bea707fd3..6a08cd78eb 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -235,7 +235,8 @@ const TimelinePanel = createReactClass({ this._initTimeline(this.props); }, - componentWillReceiveProps: function(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(newProps) { if (newProps.timelineSet !== this.props.timelineSet) { // throw new Error("changing timelineSet on a TimelinePanel is not supported"); diff --git a/src/components/structures/auth/ForgotPassword.js b/src/components/structures/auth/ForgotPassword.js index dc3f4a0a2b..9877c53106 100644 --- a/src/components/structures/auth/ForgotPassword.js +++ b/src/components/structures/auth/ForgotPassword.js @@ -74,7 +74,8 @@ export default createReactClass({ this._checkServerLiveliness(this.props.serverConfig); }, - componentWillReceiveProps: function(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(newProps) { if (newProps.serverConfig.hsUrl === this.props.serverConfig.hsUrl && newProps.serverConfig.isUrl === this.props.serverConfig.isUrl) return; diff --git a/src/components/structures/auth/Login.js b/src/components/structures/auth/Login.js index ef9d4c59c0..836e5bd93d 100644 --- a/src/components/structures/auth/Login.js +++ b/src/components/structures/auth/Login.js @@ -134,7 +134,8 @@ export default createReactClass({ this._unmounted = true; }, - componentWillReceiveProps(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(newProps) { if (newProps.serverConfig.hsUrl === this.props.serverConfig.hsUrl && newProps.serverConfig.isUrl === this.props.serverConfig.isUrl) return; diff --git a/src/components/structures/auth/Registration.js b/src/components/structures/auth/Registration.js index 45d775059c..08c2a11641 100644 --- a/src/components/structures/auth/Registration.js +++ b/src/components/structures/auth/Registration.js @@ -125,7 +125,8 @@ export default createReactClass({ this._replaceClient(); }, - componentWillReceiveProps(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(newProps) { if (newProps.serverConfig.hsUrl === this.props.serverConfig.hsUrl && newProps.serverConfig.isUrl === this.props.serverConfig.isUrl) return; diff --git a/src/components/views/auth/ServerConfig.js b/src/components/views/auth/ServerConfig.js index 37517c7484..7ec4311d2f 100644 --- a/src/components/views/auth/ServerConfig.js +++ b/src/components/views/auth/ServerConfig.js @@ -72,7 +72,8 @@ export default class ServerConfig extends React.PureComponent { }; } - componentWillReceiveProps(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(newProps) { if (newProps.serverConfig.hsUrl === this.state.hsUrl && newProps.serverConfig.isUrl === this.state.isUrl) return; diff --git a/src/components/views/avatars/BaseAvatar.js b/src/components/views/avatars/BaseAvatar.js index 4c34cee853..3e3a2e6bd9 100644 --- a/src/components/views/avatars/BaseAvatar.js +++ b/src/components/views/avatars/BaseAvatar.js @@ -74,7 +74,8 @@ export default createReactClass({ this.context.removeListener('sync', this.onClientSync); }, - componentWillReceiveProps: function(nextProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(nextProps) { // work out if we need to call setState (if the image URLs array has changed) const newState = this._getState(nextProps); const newImageUrls = newState.imageUrls; diff --git a/src/components/views/avatars/MemberAvatar.js b/src/components/views/avatars/MemberAvatar.js index a07a184aa1..826aa5fddf 100644 --- a/src/components/views/avatars/MemberAvatar.js +++ b/src/components/views/avatars/MemberAvatar.js @@ -51,7 +51,8 @@ export default createReactClass({ return this._getState(this.props); }, - componentWillReceiveProps: function(nextProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(nextProps) { this.setState(this._getState(nextProps)); }, diff --git a/src/components/views/avatars/RoomAvatar.js b/src/components/views/avatars/RoomAvatar.js index c79e1827da..a72d318b8d 100644 --- a/src/components/views/avatars/RoomAvatar.js +++ b/src/components/views/avatars/RoomAvatar.js @@ -63,7 +63,8 @@ export default createReactClass({ } }, - componentWillReceiveProps: function(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(newProps) { this.setState({ urls: this.getImageUrls(newProps), }); diff --git a/src/components/views/dialogs/DevtoolsDialog.js b/src/components/views/dialogs/DevtoolsDialog.js index 0f3fa8f5b5..a07750a768 100644 --- a/src/components/views/dialogs/DevtoolsDialog.js +++ b/src/components/views/dialogs/DevtoolsDialog.js @@ -267,7 +267,8 @@ class FilteredList extends React.PureComponent { }; } - componentWillReceiveProps(nextProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(nextProps) { if (this.props.children === nextProps.children && this.props.query === nextProps.query) return; this.setState({ filteredChildren: FilteredList.filterChildren(nextProps.children, nextProps.query), diff --git a/src/components/views/elements/AddressSelector.js b/src/components/views/elements/AddressSelector.js index febe0ff480..ab29723a45 100644 --- a/src/components/views/elements/AddressSelector.js +++ b/src/components/views/elements/AddressSelector.js @@ -46,7 +46,8 @@ export default createReactClass({ }; }, - componentWillReceiveProps: function(props) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(props) { // Make sure the selected item isn't outside the list bounds const selected = this.state.selected; const maxSelected = this._maxSelected(props.addressList); diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 8940a175e9..7696db9cf6 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -262,7 +262,8 @@ export default class AppTile extends React.Component { }); } - componentWillReceiveProps(nextProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(nextProps) { if (nextProps.app.url !== this.props.app.url) { this._getNewState(nextProps); // Fetch IM token for new URL if we're showing and have permission to load diff --git a/src/components/views/elements/Dropdown.js b/src/components/views/elements/Dropdown.js index ed5928eb08..2651f8e039 100644 --- a/src/components/views/elements/Dropdown.js +++ b/src/components/views/elements/Dropdown.js @@ -128,7 +128,8 @@ export default class Dropdown extends React.Component { document.removeEventListener('click', this._onDocumentClick, false); } - componentWillReceiveProps(nextProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(nextProps) { if (!nextProps.children || nextProps.children.length === 0) { return; } diff --git a/src/components/views/elements/EditableText.js b/src/components/views/elements/EditableText.js index af05600e3c..82f5eef125 100644 --- a/src/components/views/elements/EditableText.js +++ b/src/components/views/elements/EditableText.js @@ -62,7 +62,8 @@ export default createReactClass({ }; }, - componentWillReceiveProps: function(nextProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(nextProps) { if (nextProps.initialValue !== this.props.initialValue) { this.value = nextProps.initialValue; if (this._editable_div.current) { diff --git a/src/components/views/elements/Flair.js b/src/components/views/elements/Flair.js index 0af772466b..a8c804c534 100644 --- a/src/components/views/elements/Flair.js +++ b/src/components/views/elements/Flair.js @@ -81,7 +81,8 @@ export default class Flair extends React.Component { this._unmounted = true; } - componentWillReceiveProps(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(newProps) { this._generateAvatars(newProps.groups); } diff --git a/src/components/views/elements/Pill.js b/src/components/views/elements/Pill.js index 28a26be06c..1e31c634f7 100644 --- a/src/components/views/elements/Pill.js +++ b/src/components/views/elements/Pill.js @@ -82,7 +82,8 @@ const Pill = createReactClass({ }; }, - async componentWillReceiveProps(nextProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + async UNSAFE_componentWillReceiveProps(nextProps) { let resourceId; let prefix; @@ -158,7 +159,7 @@ const Pill = createReactClass({ componentDidMount() { this._unmounted = false; this._matrixClient = MatrixClientPeg.get(); - this.componentWillReceiveProps(this.props); // HACK: We shouldn't be calling lifecycle functions ourselves. + this.UNSAFE_componentWillReceiveProps(this.props); // HACK: We shouldn't be calling lifecycle functions ourselves. }, componentWillUnmount() { diff --git a/src/components/views/elements/PowerSelector.js b/src/components/views/elements/PowerSelector.js index 43fd3c2f84..948b4835d5 100644 --- a/src/components/views/elements/PowerSelector.js +++ b/src/components/views/elements/PowerSelector.js @@ -67,7 +67,8 @@ export default createReactClass({ this._initStateFromProps(this.props); }, - componentWillReceiveProps: function(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(newProps) { this._initStateFromProps(newProps); }, diff --git a/src/components/views/elements/SyntaxHighlight.js b/src/components/views/elements/SyntaxHighlight.js index bce65cf1a9..a4dc97d46e 100644 --- a/src/components/views/elements/SyntaxHighlight.js +++ b/src/components/views/elements/SyntaxHighlight.js @@ -31,7 +31,6 @@ export default class SyntaxHighlight extends React.Component { } // componentDidUpdate used here for reusability - // componentWillReceiveProps fires too early to call highlightBlock on. componentDidUpdate() { if (this._el) highlightBlock(this._el); } diff --git a/src/components/views/groups/GroupMemberInfo.js b/src/components/views/groups/GroupMemberInfo.js index 95517ef548..9f5660386b 100644 --- a/src/components/views/groups/GroupMemberInfo.js +++ b/src/components/views/groups/GroupMemberInfo.js @@ -54,7 +54,8 @@ export default createReactClass({ this._initGroupStore(this.props.groupId); }, - componentWillReceiveProps(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(newProps) { if (newProps.groupId !== this.props.groupId) { this._unregisterGroupStore(this.props.groupId); this._initGroupStore(newProps.groupId); diff --git a/src/components/views/groups/GroupRoomInfo.js b/src/components/views/groups/GroupRoomInfo.js index 789396e719..3a20de7eca 100644 --- a/src/components/views/groups/GroupRoomInfo.js +++ b/src/components/views/groups/GroupRoomInfo.js @@ -51,7 +51,8 @@ export default createReactClass({ this._initGroupStore(this.props.groupId); }, - componentWillReceiveProps(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(newProps) { if (newProps.groupId !== this.props.groupId) { this._unregisterGroupStore(this.props.groupId); this._initGroupStore(newProps.groupId); diff --git a/src/components/views/rooms/AppsDrawer.js b/src/components/views/rooms/AppsDrawer.js index 785d7ecccb..f7c5e8122f 100644 --- a/src/components/views/rooms/AppsDrawer.js +++ b/src/components/views/rooms/AppsDrawer.js @@ -71,7 +71,8 @@ export default createReactClass({ if (this.dispatcherRef) dis.unregister(this.dispatcherRef); }, - componentWillReceiveProps(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(newProps) { // Room has changed probably, update apps this._updateApps(); }, diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index a381a02d80..aed2d4b25b 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -254,7 +254,8 @@ export default createReactClass({ } }, - componentWillReceiveProps: function(nextProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(nextProps) { // re-check the sender verification as outgoing events progress through // the send process. if (nextProps.eventSendStatus !== this.props.eventSendStatus) { diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index b387cefe91..9fdd2abedf 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -103,7 +103,8 @@ export default createReactClass({ this._updateStateForNewMember(this.props.member); }, - componentWillReceiveProps: function(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(newProps) { if (this.props.member.userId !== newProps.member.userId) { this._updateStateForNewMember(newProps.member); } diff --git a/src/components/views/rooms/RoomTile.js b/src/components/views/rooms/RoomTile.js index 2c7ef8b6c0..0b06be48af 100644 --- a/src/components/views/rooms/RoomTile.js +++ b/src/components/views/rooms/RoomTile.js @@ -283,7 +283,8 @@ export default createReactClass({ } }, - componentWillReceiveProps: function(props) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(props) { // XXX: This could be a lot better - this makes the assumption that // the notification count may have changed when the properties of // the room tile change. diff --git a/src/components/views/settings/ChangeAvatar.js b/src/components/views/settings/ChangeAvatar.js index 76644d38bc..d8baafd1bb 100644 --- a/src/components/views/settings/ChangeAvatar.js +++ b/src/components/views/settings/ChangeAvatar.js @@ -59,7 +59,8 @@ export default createReactClass({ MatrixClientPeg.get().on("RoomState.events", this.onRoomStateEvents); }, - componentWillReceiveProps: function(newProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps: function(newProps) { if (this.avatarSet) { // don't clobber what the user has just set return; diff --git a/src/components/views/settings/discovery/EmailAddresses.js b/src/components/views/settings/discovery/EmailAddresses.js index afc538bd33..3a5a28fc43 100644 --- a/src/components/views/settings/discovery/EmailAddresses.js +++ b/src/components/views/settings/discovery/EmailAddresses.js @@ -58,7 +58,8 @@ export class EmailAddress extends React.Component { }; } - componentWillReceiveProps(nextProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(nextProps) { const { bound } = nextProps.email; this.setState({ bound }); } diff --git a/src/components/views/settings/discovery/PhoneNumbers.js b/src/components/views/settings/discovery/PhoneNumbers.js index 9addcda093..813623b7b9 100644 --- a/src/components/views/settings/discovery/PhoneNumbers.js +++ b/src/components/views/settings/discovery/PhoneNumbers.js @@ -50,7 +50,8 @@ export class PhoneNumber extends React.Component { }; } - componentWillReceiveProps(nextProps) { + // TODO: [REACT-WARNING] Replace with appropriate lifecycle event + UNSAFE_componentWillReceiveProps(nextProps) { const { bound } = nextProps.msisdn; this.setState({ bound }); }