Clear all state fields on select change

This commit is contained in:
Maciej Ziarkowski 2019-10-16 13:11:25 +01:00
parent b81d49df43
commit f189ae603e

View File

@ -81,10 +81,14 @@ const withCopyEdit = (WrappedComponent) => {
}
static getDerivedStateFromProps(props, state) {
if(props.building != undefined && props.building.building_id !== state.currentBuildingId) {
const newBuildingId = props.building == undefined ? undefined : props.building.building_id;
if(newBuildingId !== state.currentBuildingId) {
return {
error: undefined,
copying: false,
keys_to_copy: {},
buildingEdits: {},
currentBuildingId: props.building.building_id
currentBuildingId: newBuildingId
};
}