I have one local variable that is controlled by useState
that should be set after calling useCallback. However, after debug I do not see the info
is set. Looking for different solution in stackoverflow. but still do not know how to fix it
import { useCallback, useState } from "react";import "./styles.css";export default function App() { const [info, setInfo] = useState<object>({}); const handleOnClick = useCallback(() => { console.log(info);//{} setInfo({ name: "name1", address: "1234" }); console.log(info);//{} }, [info]); return (<div className="App"><button onClick={handleOnClick}>Hello</button></div> );}