Skip to content

Instantly share code, notes, and snippets.

@RyotoNoguchi
Last active December 18, 2021 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyotoNoguchi/7b02834771eb5852e3e898ba97903d93 to your computer and use it in GitHub Desktop.
Save RyotoNoguchi/7b02834771eb5852e3e898ba97903d93 to your computer and use it in GitHub Desktop.
Sample of a functional components
import React from "react";
export type Choices = {
A: string
B: string
C: string
D: string
}
export type QuestionType = {
id: string
question: string
answer: string
choices: Choices
}
const SampleQuestion: React.VFC<QuestionType> = ({id, question, answer, choices}) => {
return (
<div>
<h1>問題{id}</h1>
<h2>問題文:{question}</h2>
<ul>
<li>選択肢A:{choices.A}</li>
<li>選択肢B:{choices.B}</li>
<li>選択肢C:{choices.C}</li>
<li>選択肢D:{choices.D}</li>
</ul>
<h2>正解: {answer}</h2>
</div>
);
}
export default SampleQuestion;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment