diff --git a/src/components/binary.tsx b/src/components/binary.tsx new file mode 100644 index 0000000..2976906 --- /dev/null +++ b/src/components/binary.tsx @@ -0,0 +1,17 @@ +import { useState, useEffect } from 'react'; + +import { generateRandomBinaryString } from '@/helpers/binary'; + +export function Binary() { + const [binary, setBinary] = useState(''); + + useEffect(() => { + setBinary(generateRandomBinaryString(1000)); + + setInterval(() => { + setBinary(generateRandomBinaryString(1000)); + }, 200); + }, []); + + return {binary}; +} diff --git a/src/components/source.astro b/src/components/source.astro index 29ab5e0..3a99113 100644 --- a/src/components/source.astro +++ b/src/components/source.astro @@ -3,10 +3,7 @@ import { FaGithub } from 'react-icons/fa/index'; import { SpecialButton } from './special-button'; import { Container } from './container'; - -import { generateRandomBinaryString } from '@/helpers/binary'; - -const binary = generateRandomBinaryString(1000); +import { Binary } from './binary'; ---