Skip to content

Commit a5e752b

Browse files
committed
add fallback to NoSSR
1 parent f36483d commit a5e752b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

client.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { useEffect, useState } from "react";
22

3-
export function NoSSR({ children }: { children: React.ReactElement }) {
4-
const [state, setState] = useState<React.ReactElement | null>(null);
3+
export function NoSSR({
4+
children,
5+
fallback,
6+
}: {
7+
children: React.ReactNode;
8+
fallback?: React.ReactNode;
9+
}) {
10+
const [state, setState] = useState<React.ReactNode>(fallback);
511
useEffect(() => setState(children), [children]);
612
return <>{state}</>;
713
}

0 commit comments

Comments
 (0)