From 538e282612aaf409f6ecb99eeaab6fcacdfbe18f Mon Sep 17 00:00:00 2001 From: David Bismut Date: Thu, 21 Mar 2024 16:00:32 +0100 Subject: [PATCH] docs: fix random() SSR bug --- documentation/pages/docs/code/rug.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/documentation/pages/docs/code/rug.js b/documentation/pages/docs/code/rug.js index f24ea6aa6..a27201deb 100644 --- a/documentation/pages/docs/code/rug.js +++ b/documentation/pages/docs/code/rug.js @@ -1,14 +1,18 @@ -import React from 'react' +import React, { useEffect } from 'react' import { EasterDiv } from './examples' const handMojis = ['👆', '👇', '👈', '🤘', '🤙', '✊', '🖖', '🖐', '🤞', '👍', '👊'] const randomEmoji = () => handMojis[Math.floor(Math.random() * handMojis.length)] export default function Rug({ pkg }) { + const [emoji, setEmoji] = React.useState(handMojis[0]) + + useEffect(() => setEmoji(randomEmoji()), []) + return ( - {randomEmoji()} @use-gesture + {emoji} @use-gesture {pkg && `/${pkg}`}