Я хочу сохранить несколько деталей значения состояния в пожарном депо.Как мне этого добиться?
state = {
sp_Name: '',
sp_Phone: '',
sp_email: '',
sp_Role: 'Fleet Provider',
usr_org_LicenseNumber: '',
sp_License:'',
usr_org_StateConvered: '',
usr_org_DistConvered: '',
EquipmentCount: 0,
loading:false,
checked: false,
disChecked : false,
open: false,
message:'',
sp_NameError: '',
sp_PhoneError: '',
sp_emailError: '',
usr_org_LicenseNumberError: '',
sp_LicenseError:'',
usr_org_StateConveredError: '',
usr_org_DistConveredError: '',
sp_NumberofEquipmentsError:'',
};
Я удаляю некоторые детали, но есть ли другой способ удалить все сразу.
const stateObj = this.state;
delete stateObj['loading'];
delete stateObj['checked'];
delete stateObj['disChecked'];
delete stateObj['open'];
delete stateObj['message'];
delete stateObj['sp_NameError','sp_PhoneError','sp_emailError'];
delete stateObj['usr_org_LicenseNumberError', 'sp_LicenseError','usr_org_StateConveredError',
'usr_org_DistConveredError','sp_NumberofEquipmentsError'];
this.props.UpdateUserDetails(uid, stateObj)
this.openSnackbar({ message: 'Submitted Successfully.!' });