const _id = match.params.id;
const response = await api.get("/roleidindex", {
params: {
_id
}
})
console.log (response.data); //correct object
setRole(response.data);
console.log (role); //{}
In my code I have this piece of text and, as the comments show the response from the request are fine, but when I set the state to the value, the state remains the same as its initial one. That is all inside a useEffect method, by the way.