|
Download react-use/docs/useFirstMountState.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 589 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useFirstMountState.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-use/docs/useFirstMountState.md
-
curl -L -o useFirstMountState.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useFirstMountState.md
589 Bytes
useFirstMountState
Returns true if component is just mounted (on first render) and false otherwise.
Usage
import * as React from 'react';
import { useFirstMountState } from 'react-use';
const Demo = () => {
const isFirstMount = useFirstMountState();
const update = useUpdate();
return (
<div>
<span>This component is just mounted: {isFirstMount ? 'YES' : 'NO'}</span>
<br />
<button onClick={update}>re-render</button>
</div>
);
};
Reference
const isFirstMount: boolean = useFirstMountState();