From 0fc92b46a76c94268c5f1c00162cdec37770762b Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 30 Jul 2020 11:18:55 +0300 Subject: [PATCH] Edit pages: remove UNSAFE componentsWillReceiveProps. --- src/Pim/index.tsx | 3 +++ src/components/ContactEdit.tsx | 15 --------------- src/components/EventEdit.tsx | 15 --------------- src/components/Tasks/TaskEdit.tsx | 15 --------------- 4 files changed, 3 insertions(+), 45 deletions(-) diff --git a/src/Pim/index.tsx b/src/Pim/index.tsx index e160c7f..c9286dd 100644 --- a/src/Pim/index.tsx +++ b/src/Pim/index.tsx @@ -157,6 +157,7 @@ const CollectionRoutes = withStyles(styles)(withRouter( render={() => ( {(itemUid in props.items) && {(itemUid in props.items) && { this.onDeleteRequest = this.onDeleteRequest.bind(this); } - public UNSAFE_componentWillReceiveProps(nextProps: any) { - if ((this.props.collections !== nextProps.collections) || - (this.props.initialCollection !== nextProps.initialCollection)) { - if (nextProps.initialCollection) { - this.setState({ - journalUid: nextProps.initialCollection, - }); - } else if (nextProps.collections[0]) { - this.setState({ - journalUid: nextProps.collections[0].uid, - }); - } - } - } - public addValueType(name: string, _type?: string) { const type = _type ? _type : 'home'; this.setState((prevState) => { diff --git a/src/components/EventEdit.tsx b/src/components/EventEdit.tsx index 726eed7..b9ee0bc 100644 --- a/src/components/EventEdit.tsx +++ b/src/components/EventEdit.tsx @@ -148,21 +148,6 @@ class EventEdit extends React.PureComponent { this.handleCloseToast = this.handleCloseToast.bind(this); } - public UNSAFE_componentWillReceiveProps(nextProps: any) { - if ((this.props.collections !== nextProps.collections) || - (this.props.initialCollection !== nextProps.initialCollection)) { - if (nextProps.initialCollection) { - this.setState({ - journalUid: nextProps.initialCollection, - }); - } else if (nextProps.collections[0]) { - this.setState({ - journalUid: nextProps.collections[0].uid, - }); - } - } - } - public handleChange(name: string, value: string) { this.setState({ [name]: value, diff --git a/src/components/Tasks/TaskEdit.tsx b/src/components/Tasks/TaskEdit.tsx index 6c37b69..b1dea69 100644 --- a/src/components/Tasks/TaskEdit.tsx +++ b/src/components/Tasks/TaskEdit.tsx @@ -142,21 +142,6 @@ class TaskEdit extends React.PureComponent { this.handleCloseToast = this.handleCloseToast.bind(this); } - public UNSAFE_componentWillReceiveProps(nextProps: any) { - if ((this.props.collections !== nextProps.collections) || - (this.props.initialCollection !== nextProps.initialCollection)) { - if (nextProps.initialCollection) { - this.setState({ - journalUid: nextProps.initialCollection, - }); - } else if (nextProps.collections[0]) { - this.setState({ - journalUid: nextProps.collections[0].uid, - }); - } - } - } - public handleChange(name: string, value: string | number | string[]) { this.setState({ [name]: value,