Skip to content

Commit 538e282

Browse files
committed
docs: fix random() SSR bug
1 parent aa02dde commit 538e282

File tree

1 file changed

+6
-2
lines changed
  • documentation/pages/docs/code

1 file changed

+6
-2
lines changed

documentation/pages/docs/code/rug.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import React from 'react'
1+
import React, { useEffect } from 'react'
22
import { EasterDiv } from './examples'
33

44
const handMojis = ['👆', '👇', '👈', '🤘', '🤙', '✊', '🖖', '🖐', '🤞', '👍', '👊']
55
const randomEmoji = () => handMojis[Math.floor(Math.random() * handMojis.length)]
66

77
export default function Rug({ pkg }) {
8+
const [emoji, setEmoji] = React.useState(handMojis[0])
9+
10+
useEffect(() => setEmoji(randomEmoji()), [])
11+
812
return (
913
<EasterDiv>
1014
<span style={{ color: '#ff9800', touchAction: 'none' }}>
11-
{randomEmoji()} <strong>@use-gesture</strong>
15+
{emoji} <strong>@use-gesture</strong>
1216
{pkg && `/${pkg}`}
1317
</span>
1418
</EasterDiv>

0 commit comments

Comments
 (0)