I use Redux-form change function to change the state of the form. if this attribute exists, it will append the value directly to the state, if it doesn't exist, it will add this attribute with the value to the state. Is that possible to delete this key-value pair in the state?
if (language === 'English') {
change('languages', 'English');
} else if (typeof language === 'Unknown') {
*** delete languages: English from the state ***
}
var language = 'English'
expected result: { languages: English }
var language = 'Unknow'
expected result: {}
const { languages, ...newState } = stateVariableHere
thennewState
will not have the property. But I would recommend against this: you want state to have a consistent shape. So nullify languages instead of removing. - Andrew Lilanguages
field or set it to undefined? - faithfull