Edit pages: remove UNSAFE componentsWillReceiveProps.

master
Tom Hacohen 4 years ago
parent e38181a8ae
commit 0fc92b46a7

@ -157,6 +157,7 @@ const CollectionRoutes = withStyles(styles)(withRouter(
render={() => ( render={() => (
<Container style={{ maxWidth: '30rem' }}> <Container style={{ maxWidth: '30rem' }}>
<ComponentEdit <ComponentEdit
key={props.routePrefix}
collections={props.collections} collections={props.collections}
onSave={props.onItemSave} onSave={props.onItemSave}
onCancel={props.onItemCancel} onCancel={props.onItemCancel}
@ -177,6 +178,7 @@ const CollectionRoutes = withStyles(styles)(withRouter(
<Container style={{ maxWidth: '30rem' }}> <Container style={{ maxWidth: '30rem' }}>
{(itemUid in props.items) && {(itemUid in props.items) &&
<ComponentEdit <ComponentEdit
key={(props.items[itemUid] as any).journalUid}
initialCollection={(props.items[itemUid] as any).journalUid} initialCollection={(props.items[itemUid] as any).journalUid}
item={props.items[itemUid]} item={props.items[itemUid]}
collections={props.collections} collections={props.collections}
@ -203,6 +205,7 @@ const CollectionRoutes = withStyles(styles)(withRouter(
<Container style={{ maxWidth: '30rem' }}> <Container style={{ maxWidth: '30rem' }}>
{(itemUid in props.items) && {(itemUid in props.items) &&
<ComponentEdit <ComponentEdit
key={(props.items[itemUid] as any).journalUid}
initialCollection={(props.items[itemUid] as any).journalUid} initialCollection={(props.items[itemUid] as any).journalUid}
item={props.items[itemUid]} item={props.items[itemUid]}
collections={props.collections} collections={props.collections}

@ -240,21 +240,6 @@ class ContactEdit extends React.PureComponent<PropsType> {
this.onDeleteRequest = this.onDeleteRequest.bind(this); 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) { public addValueType(name: string, _type?: string) {
const type = _type ? _type : 'home'; const type = _type ? _type : 'home';
this.setState((prevState) => { this.setState((prevState) => {

@ -148,21 +148,6 @@ class EventEdit extends React.PureComponent<PropsType> {
this.handleCloseToast = this.handleCloseToast.bind(this); 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) { public handleChange(name: string, value: string) {
this.setState({ this.setState({
[name]: value, [name]: value,

@ -142,21 +142,6 @@ class TaskEdit extends React.PureComponent<PropsType> {
this.handleCloseToast = this.handleCloseToast.bind(this); 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[]) { public handleChange(name: string, value: string | number | string[]) {
this.setState({ this.setState({
[name]: value, [name]: value,

Loading…
Cancel
Save