wsmd/react-use-form-state

setField should not be packaged with formState

keeganstothert opened this issue · 2 comments

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:

https://codesandbox.io/s/bold-brown-z7o98?expanddevtools=1

@wsmd I recant; I was confusing this with #105 (which has been resolved).