Skip to content

Commit 775beb0

Browse files
authored
fix: hydration error (#1445)
Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>
1 parent f05c033 commit 775beb0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

website/src/components/Testimonials/index.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,18 @@ const getRandomTestimonial = () => {
5757
};
5858

5959
export default function Testimonials(): JSX.Element {
60-
const review = getRandomTestimonial();
60+
const [review, setReview] = React.useState<typeof testimonials[number] | null>(
61+
null
62+
);
63+
64+
React.useEffect(() => {
65+
const randomIndex = Math.floor(Math.random() * testimonials.length);
66+
setReview(testimonials[randomIndex]);
67+
}, []);
68+
69+
if (!review) {
70+
return null;
71+
}
6172

6273
return (
6374
<div className={styles.testimonialsList}>

0 commit comments

Comments
 (0)