- Lab
- Core Tech

Build a Quiz Component with React

Path Info
Table of Contents
-
Challenge
Creating a Quiz Component
In this lab you’ll follow along with our instructions and build a simple quiz component with React 17.x. You’ll create several components across different files, pass data as props, and propagate events up and down a chain of components.
In this module you'll create a Quiz component to display quiz information from state that contains data from a local JSON file. ### Solution The solution can be found in the
solution
directory. -
Challenge
Creating a QuizQuestion Component
In this module you'll refactor the Quiz component to display quiz question data in a new component named QuizQuestion.
-
Challenge
Creating a QuizQuestionButton Component
In this module you'll refactor the QuizQuestion component to display quiz answer buttons in a new component named QuizQuestionButton.
-
Challenge
Creating a QuizEnd Component
In this module you'll create a QuizEnd component that will display a reset quiz link after the quiz is completed.
-
Challenge
Displaying Quiz Questions and Handling Events
In this module you'll refactor the QuizQuestion component to iterate over an array of questions and display multiple QuizQuestionButtons. Then, you'll create methods and event handlers that call them when the button tag in a QuizQuestionButton component is clicked and have those methods increment the position value in the Quiz component's state.
-
Challenge
Displaying An Error Message Based on State
In this module you'll add state to the QuizQuestion class that tracks if a questions was answered incorrectly, and display an error message if the last answer was incorrect.
-
Challenge
Resetting the Quiz
In this module you'll add methods and event handlers that call them when the anchor tag in the QuizEnd component is clicked, and have those methods reset the position value in the Quiz component's state.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.