function Example() { const [state, setState] = useState(0) const someFunction= ()=>{ ///some task that return a value let value = getFunction() setState(value) console.log(state) //prints 0 ??? } return ( <></> ); } export default Example;
As you can see, the status has not changed. What can I do to solve this problem. I also tried using useEffect
I tried using useEffect without success
This is from the React documentation:
This is also very interesting.