我目前正在嘗試將最新更新獲取到超時函數中。這意味著我想更新到而不必使用類似鉤子的東西。c1useRefconst [c, s] = useState<number>(0) const f = () => { s(1) setTimeout(() => console.log(c), 600) } return ( <div style={{ width: '100%', height: '100%', backgroundColor: 'black' }} onMouseEnter={f} > test </div> )
如何在超時函數中獲取更新的 useState() 值?
縹緲止盈
2022-09-02 16:22:17
