implement review comments
This commit is contained in:
parent
d485e95e7b
commit
e2de45db23
|
@ -119,20 +119,19 @@
|
||||||
|
|
||||||
const clearValue = () => {
|
const clearValue = () => {
|
||||||
const { fieldState } = fieldMap[field]
|
const { fieldState } = fieldMap[field]
|
||||||
|
const newValue = initialValues[field] ?? defaultValue;
|
||||||
fieldState.update(state => {
|
fieldState.update(state => {
|
||||||
state.value = defaultValue
|
state.value = newValue
|
||||||
state.error = null
|
state.error = null
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
|
|
||||||
formState.update(state => {
|
formState.update(state => {
|
||||||
state.values = { ...state.values, [field]: defaultValue }
|
state.values = { ...state.values, [field]: newValue }
|
||||||
delete state.errors[field]
|
delete state.errors[field]
|
||||||
state.valid = Object.keys(state.errors).length === 0
|
state.valid = Object.keys(state.errors).length === 0
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue