I am not much familiar with React. Tried to set state as an object by fetching from api. The fetching returns correct object but setting state is not working at all.
const [data, setData] = useState({});
useEffect(async () => {
const res = await fetch("/api/user");
const json = await res.json();
console.log(json); // {name: "Diego", email:"xxxx@xyz.com"}
setData(json);
console.log(data); // {} :(
}, []);