Skip to content

Commit

Permalink
docs: fix random() SSR bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dbismut committed Mar 21, 2024
1 parent aa02dde commit 538e282
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions documentation/pages/docs/code/rug.js
Original file line number Diff line number Diff line change
@@ -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 (
<EasterDiv>
<span style={{ color: '#ff9800', touchAction: 'none' }}>
{randomEmoji()} <strong>@use-gesture</strong>
{emoji} <strong>@use-gesture</strong>
{pkg && `/${pkg}`}
</span>
</EasterDiv>
Expand Down

0 comments on commit 538e282

Please sign in to comment.