From 737344a72d23dc97b0d0e73cc4ab7fdffd0fbf49 Mon Sep 17 00:00:00 2001 From: Brendan F Date: Sun, 14 May 2023 23:12:27 -0700 Subject: Merge in react app code From sluchajfun and youtube-heardle-template --- src/components/Guess/index.tsx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/components/Guess/index.tsx (limited to 'src/components/Guess/index.tsx') diff --git a/src/components/Guess/index.tsx b/src/components/Guess/index.tsx new file mode 100644 index 0000000..2afd35c --- /dev/null +++ b/src/components/Guess/index.tsx @@ -0,0 +1,32 @@ +import React from "react"; + +import { GuessType } from "../../types/guess"; + +import * as Styled from "./index.styled"; + +interface Props { + guess: GuessType; + isCorrect: boolean | undefined; + active: boolean; +} + +export function Guess({ guess, isCorrect, active }: Props) { + const { song, skipped } = guess; + const [text, setText] = React.useState(""); + + React.useEffect(() => { + if (song) { + setText(`${song.artist} - ${song.name}`); + } else if (skipped) { + setText("Skipped"); + } else { + setText(""); + } + }, [guess]); + + return ( + + {text} + + ); +} -- cgit v1.2.3