Skip to content

Commit 0f2805e

Browse files
committed
fix deepsource
1 parent b862fb0 commit 0f2805e

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

lib/src/client/type-out/utils.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import styles from "./type-out.module.scss";
66
* Supports waiting durations as numeric values.
77
*/
88
export const setupTypingFX = (children: ReactNode): ReactNode => {
9+
/** recursively setup the node */
910
const handleNode = (node: ReactNode): ReactNode => {
1011
if (Array.isArray(node)) return node.map(handleNode);
1112

packages/shared/src/client/demo/demo.tsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ import { TypeOut } from "typingfx";
44
import styles from "./demo.module.scss";
55
import { useEffect, useMemo, useState } from "react";
66

7+
const steps = [
8+
<div key={0}>Hare</div>,
9+
<div key={1}>
10+
Hare <span style={{ color: "green" }}>Krishna</span> Hare Krishna Hare Krishna
11+
<p>Hare Krishna</p>
12+
<p>{3000}Hare Rama</p>
13+
</div>,
14+
<p key={2}>Hare Krishna {3000} Hare Krishna Krishna Krishna Hare Hare</p>,
15+
<p key={3}>Hare Krishna Hare Krishna Hare Rama Hare Rama</p>,
16+
];
717
/** React live demo */
818
export function Demo() {
919
const [paused, setPaused] = useState(false);
@@ -13,25 +23,20 @@ export function Demo() {
1323
setUser({ name: "Mayank" });
1424
}, 3000);
1525
}, []);
16-
const steps = [
17-
<div key={0}>Hare</div>,
18-
<div key={1}>
19-
Hare <span style={{ color: "green" }}>Krishna</span> Hare Krishna Hare Krishna
20-
<p>Hare Krishna</p>
21-
<p>{3000}Hare Rama</p>
22-
</div>,
23-
<p key={2}>Hare Krishna {3000} Hare Krishna Krishna Krishna Hare Hare</p>,
24-
<p key={3}>Hare Krishna Hare Krishna Hare Rama Hare Rama</p>,
25-
];
26-
const welcome = (
27-
<>
28-
{1000}Welcome <i>{`${user?.name},`}</i> {500}How can I help you?{-3000}
29-
</>
26+
const welcome = useMemo(
27+
() => (
28+
<>
29+
{1000}Welcome <i>{`${user?.name},`}</i> {500}How can I help you?{-3000}
30+
</>
31+
),
32+
[user],
3033
);
3134
return (
3235
<div className={styles.demo}>
3336
<button onClick={() => setPaused(!paused)}>{paused ? "Resume" : "Pause"}</button>
34-
<TypeOut paused={paused}>{welcome}</TypeOut>
37+
<TypeOut paused={paused} steps={steps}>
38+
{welcome}
39+
</TypeOut>
3540
</div>
3641
);
3742
}

0 commit comments

Comments
 (0)