wsmd / react-use-form-state

📄 React hook for managing forms and inputs state

Home Page:http://react-use-form-state.now.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setField should not be packaged with formState

keeganstothert opened this issue · 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()!

@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).