-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathloop.tsx
More file actions
36 lines (28 loc) · 717 Bytes
/
loop.tsx
File metadata and controls
36 lines (28 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import React from "react";
import { useDencrypt } from "..";
const values = ["useDencrypt", "Customizable", "React Hook", "Text Effect", ""];
export const Loop = () => {
const [result, setResult] = useDencrypt();
React.useEffect(() => {
let i = 0;
let run = true;
const loop = async () => {
while (run) {
await new Promise((resolve) => setTimeout(resolve, 1000));
await setResult(values[i]);
i = i === values.length - 1 ? 0 : i + 1;
}
};
loop();
return () => {
run = false;
};
}, [setResult]);
return (
<div
style={{ fontFamily: "monospace", fontSize: "4rem", minHeight: "4rem" }}
>
{result}
</div>
);
};