useIsFirstRender()
2022年5月1日小于 1 分钟
useIsFirstRender()
Question
Create a hook to tell if it is the first render.
function App() {
const isFirstRender = useIsFirstRender()
// only true for the first render
...
}
Code
export function useIsFirstRender(): boolean {
// your code here
}
// if you want to try your code on the right panel
// remember to export App() component like below
// export function App() {
// return <div>your app</div>
// }