Skip to content

Instantly share code, notes, and snippets.

@kyleshevlin
Last active May 21, 2020 15:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleshevlin/5d5482d30f895840d29346d10be99f03 to your computer and use it in GitHub Desktop.
Save kyleshevlin/5d5482d30f895840d29346d10be99f03 to your computer and use it in GitHub Desktop.
const NEXT_DOTS = {
'': '.',
'.': '. .',
'. .': '. . .',
'. . .': '',
}
function Dots() {
const [dots, setDots] = React.useState('')
React.useEffect(() => {
const intervalId = setInterval(() => {
setDots(d => NEXT_DOTS[d])
}, 350)
return () => clearInterval(intervalId)
}, [])
return (
<div
css={{
display: 'inline-block',
textAlign: 'center',
width: 30,
}}
>
{dots}
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment