import { ReactComponentElement, ReactNode } from "react"; import { AnswerType, Question } from "../lib/question"; import { SessionState } from "../lib/session"; const QuestionView = ({ question, setState, state }: { question: Question, setState: any, state: SessionState }) => { const handleOpenClick = () => { setState( (prevState: SessionState) => ({ ...prevState, opened: { ...prevState.opened, [question.id]: !prevState.opened[ question.id ] } })) } const handleAnswerClick = (right: boolean) => { setState( (prevState: SessionState) => ({ ...prevState, answer: { ...prevState.answer, [question.id]: right ? AnswerType.Right : AnswerType.Wrong } })) question.answered = right ? AnswerType.Right : AnswerType.Wrong; } return (
{question.answer}
) : null}