diff --git a/Quiz/src/jsx/App.jsx b/Quiz/src/jsx/App.jsx index 03b20d2..fb40a24 100755 --- a/Quiz/src/jsx/App.jsx +++ b/Quiz/src/jsx/App.jsx @@ -40,11 +40,11 @@ class App extends React.Component { _handleSubmit() { if (this.state.index + 1 < this.state.numberOfQuestions) { - this.setState({ + this.setState({ index : this.state.index + 1 }) } else { - this.setState({ + this.setState({ completed : true }) } @@ -64,24 +64,22 @@ class App extends React.Component { score: (correctAnswer === selection) ? this.state.score + 1 : this.state.score, selectionMade:false }) - + } render() { - + const quizCompleted =

Quiz completed !

; const quiz =
- +
; const quizStage = !this.state.completed ? quiz : quizCompleted ; @@ -92,10 +90,10 @@ class App extends React.Component {
{quizStage}
- + ) } } -export default App; \ No newline at end of file +export default App; diff --git a/Quiz/src/jsx/components/Answer.jsx b/Quiz/src/jsx/components/Answer.jsx index 1a86ebf..d0d4200 100755 --- a/Quiz/src/jsx/components/Answer.jsx +++ b/Quiz/src/jsx/components/Answer.jsx @@ -1,32 +1,30 @@ import React from "react"; -class Answer extends React.Component{ - constructor(props) { - super(props); +const Answer = props => ( +
+ {props.options.map((option,i) => ( +
+ { + props.handleRadio(i) + }} + /> + +
+ ))} - } + +
+); - render() { - - const options = this.props.options.map( (option,i) => { - return
- - -
- }); - - return( -
- {options} - -
- ) - } -} - - -export default Answer; \ No newline at end of file +export default Answer; diff --git a/Quiz/src/jsx/components/Question.jsx b/Quiz/src/jsx/components/Question.jsx index 1a2604b..7981bd4 100755 --- a/Quiz/src/jsx/components/Question.jsx +++ b/Quiz/src/jsx/components/Question.jsx @@ -1,17 +1,12 @@ import React from "react"; -const Question = (props) =>{ - - const QuestionObejct = props.quiz[props.index]; - - return( -
-
- {QuestionObejct.question} -
+const Question = ({question}) => ( +
+
+ {question}
- ) -} +
+); -export default Question; \ No newline at end of file +export default Question;