We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a868a6c commit 893e102Copy full SHA for 893e102
src/useTimeout.ts
@@ -31,6 +31,20 @@ function setChainedTimeout(
31
/**
32
* Returns a controller object for setting a timeout that is properly cleaned up
33
* once the component unmounts. New timeouts cancel and replace existing ones.
34
+ *
35
36
37
+ * ```tsx
38
+ * const { set, clear } = useTimeout();
39
+ * const [hello, showHello] = useState(false);
40
+ * //Display hello after 5 seconds
41
+ * set(() => showHello(true), 5000);
42
+ * return (
43
+ * <div className="App">
44
+ * {hello ? <h3>Hello</h3> : null}
45
+ * </div>
46
+ * );
47
+ * ```
48
*/
49
export default function useTimeout() {
50
const isMounted = useMounted()
0 commit comments