implement review comments

This commit is contained in:
Maurits Lourens 2021-07-26 17:01:29 +02:00
parent f2c26a90c3
commit bb69f40a46
1 changed files with 3 additions and 4 deletions

View File

@ -119,20 +119,19 @@
const clearValue = () => {
const { fieldState } = fieldMap[field]
const newValue = initialValues[field] ?? defaultValue;
fieldState.update(state => {
state.value = defaultValue
state.value = newValue
state.error = null
return state
})
formState.update(state => {
state.values = { ...state.values, [field]: defaultValue }
state.values = { ...state.values, [field]: newValue }
delete state.errors[field]
state.valid = Object.keys(state.errors).length === 0
return state
})
return true
}
return {