With the code below - handleChange methos is used in form fields:
- starting
i = 0 - with the first change
ishould get updated withi+1- and
console.log(i)= should be 1, but get 0
- I tried to research the lifecycles and read a lot of posts, but couldn't understand how to fix it (tried to simplify the question).
Thanks
const [i, setI] = useState(0)
const handleChange = input => event => {
setI(i + 1)
console.log(i)
}
<ChildFormComponent handleChange={handleChange}/>