I am implementing a React component to make payments. And there is a part in my code where I used useEffect to setValues from useState. The Code is as follows:
React.useEffect(()=>{
axiosFetch
.get("auth/get_user")
.then(res => {
setUserName(res.data.name);
setUserEmail(res.data.email);
setUserContact(res.data.contact);
console.log(res);
console.log(userName);
console.log(userEmail);
console.log(userContact);
})
.catch(() => {})
}, [])
When I run this code the browser prints console.log(res) as expected. But it prints the other three statements as Empty Strings (I expect some other values).
Here is what the console prints.
As you can see that console.log(res) is printing correctly. Then why not the other three??