Hey so im facing this strange issue while using react-hook-form.
This is the gist of my code
const [error, setError] = useState(true)
const onSubmit = values => {
setError(false)
console.log(error) // true on first click and false on second click
}
<input type="submit" />
As you'll can see I get error as true the first time I click on input and false the second time I click it.
I expect error to be false the first time I click on input does anyone know why it's true?
Note: My form is a nested form where I use FormContext to wrap my form so I can split the form into smaller components. Could it be that that's causing this side-effect or is it just something obvious that I'm missing?