Created
April 3, 2020 15:52
-
-
Save RichardBray/3df3f37461c44380b09843f7e0b7be23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// App.jsx | |
import React, { Fragment } from "react"; | |
// - Data | |
import data from "./data.json"; | |
export default function App() { | |
function renderQuestions() { | |
return data.results.map((result, index) => ( | |
<Question key={index} {...{result, index}} /> | |
)); | |
} | |
return ( | |
<Fragment> | |
<Start /> | |
{renderQuestions()} | |
<Finish /> | |
</Fragment> | |
); | |
} | |
function Start() { | |
return ( | |
<Fragment> | |
<h1>Video games</h1> | |
<h2>How much you know about them?</h2> | |
<Button text="Let's go!" func={() => scrollToElem("question-0")} /> | |
</Fragment> | |
); | |
} | |
function Finish() { | |
return ( | |
<Fragment> | |
<h3>Well done!</h3> | |
<h4> | |
You scored {calculateResult(correctAnswers, chosenAnswers)} out of {totalQuestions} | |
</h4> | |
<Button text="start over" func={() => window.location.reload()} /> | |
</Fragment> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment