I am trying to use UseState. I know that to make sure it works instantly we have to use "useEffect". Code below logs the new values, but does not change it when it calls the prop.
useEffect(() => {
console.log(
"updated",
itemId,
highlight,
);
}, [highlight, itemId]);
Thank you in advance!
EDIT:
Example that illustrates the problem:
const [highlight, setHighLight] = useState("Old Value1");
const [itemId, setItemID] = useState("Old Value");
setItemID(New Value);
setHighlight(New Value2);
((USEEFFECT LOGS "New Value" and "New Value2"))
console.log(ItemId) == returns "Old Value"
Function where I set the itemId and print it.
await setItemID(id);
console.log(itemId);
await printSkillChart(id, peer2);