diff --git a/src/components/quiz-option.tsx b/src/components/quiz-option.tsx new file mode 100644 index 0000000..cb70ddd --- /dev/null +++ b/src/components/quiz-option.tsx @@ -0,0 +1,37 @@ +import * as React from "react"; +import { cn } from "@/lib/utils"; +import { Button } from "./ui/button"; +import { CircleCheck } from "lucide-react"; + +export type QuizOptionProps = { + onClick: () => void; + isSelected: boolean; + display: string; + value: string | boolean; +}; + +export const QuizOption = React.memo(function QuizOption({ + onClick, + isSelected, + display, + value, +}: QuizOptionProps) { + return ( + + ); +}); diff --git a/src/components/quiz.tsx b/src/components/quiz.tsx index 5d53571..82ec03d 100644 --- a/src/components/quiz.tsx +++ b/src/components/quiz.tsx @@ -2,10 +2,9 @@ import * as React from "react"; import { cn } from "@/lib/utils"; -import { Button } from "./ui/button"; -import { CircleCheck } from "lucide-react"; import { QuizNavigation } from "./quiz-navigation"; import { QuizResult } from "./quiz-result"; +import { QuizOption } from "./quiz-option"; type Option = { display: string; @@ -157,23 +156,13 @@ export function Quiz() { const isOptionSelected = currentQuestion.response === o; return ( - + isSelected={isOptionSelected} + display={o.display} + value={o.value} + /> ); })}