any idea on why my state is being changed to undefined ?
The whole situation is that I initiate my state as:
const [state, setState] = useState({
email: '',
password: '',
loading: false,
errors: {}
And then this is what updates the email and password fields:
const handleChange = (event) => {
console.log("Target:",event.target)
console.log("Name:",event.target.name, "Value:", event.target.value)
setState({
[event.target.name]: event.target.value
});
console.log("State after: ",state.email, state.password)
But the thing is, once I write one character into one of the form's fields e.g. username, other state's fields become undefined, maybe you could explain what's the problem here ?
Attached is my console screenshot and code snip.
login form

console screenshot
