setField should not be packaged with formState
keeganstothert opened this issue · 2 comments
keeganstothert commented
useEffect(() => {
formState.setField('somefield', someValue)
}, [formState, formState.setField])
the formState is automatically added as a dependency which causes an infinite loop. i can destructure...
const {setField} = formState
but it seems like setters should be seperated from state to prevent infinite loops, maybe...
const [formState, {text, raw}, { setField }] = useFormState()
this should include all functions that modify the state including future ones like setValidity()
!
wsmd commented
@keeganstothert (cc @dcousens) I'm not able to reproduce the issue. What version are you using? are you using the latest?
Please fork the following sandbox with a repro: