useUpdate
强制更新函数
Usage
实时编辑器
function Demo() { const update = useUpdate(); return ( <> {/* to avoid ssr error beacause date.now() will not be same in server and client */} <div suppressHydrationWarning={true}>Time: {Date.now()}</div> <button onClick={update}>Update</button> </> ); };
结果
Loading...
API
useUpdate
Returns
() => void
: 强制更新函数