Rajdeep Singh.

Create Modern Quiz With React Js

Learn a modern Quiz app demo here

By reactjs 2 min read

Hey, Welcome to react series My Name, Rajdeep Singh. In series, we learn about react.js, but This time, we create a small react project. The Project Name quiz app.

Watch The Demo on code sandbox And Download Code.

Download Code on GitHub: react-quiz-app

Let’s start:


  1. Basic React knowledge
  2. Code Editor or IDE
  3. Smiley Face

Learn Basic of Reactjs



  1. Create React App
  2. Learn Folder Str.
  3. Index.js File
  4. Demo Data
  5. Components

Create React App

First, Create New React Project on your laptop using create-react-app command.

npx create-react-app quiz app
cd my-app
npm start

Learn Folder Str

In the react Src folder, there are 3 components and one is data.js file.

Src folder structure

Index.js File

Index.js main file in the react src folder. we add CSS file and import component file on index.js

We import the Header and Quiz component to this place

Most Important create render Method on here.

index.js file code

Style For Quiz:

All Styles for the body, header, MainDiv as card, And a button. Create on this file.

Style CSS

Demo Data:

data.js file, I create a variable Name Quizdata. We assign data from of array in the Quizdata variable.

Each index, we create an object. in the object, we add an id, Quiz, FindAnswer, and rightAnswer

In FindAnswer, We add the array with three values.

Data.js file




Quiz components work with 5 step

1 step:

Create the state. In-State we create an object. in this object, we create a dataQuestion variable with an array

2 step

We create a function. function name setStateFunstion in this function use react setState method And set data form data.js

3 step

ComponentDidMount simple we call setStateFunstion

4 step

In this step, we use map(). Map function work with an array. In this array map() get data and then we return h2 and Answer component.

Answer Components access data help props we provide here.




with two-step to learn Answer.js

1 step

Create a state with 3 parameters first Answer, second clickCheck, and third rightAnaswer.

2 step

We use javascript ternary operator, map function, and event function to clickCheck true to get value to return a button. In this button, we call an Event function.

When some buddy clicks on the button, the button function uses The setState method set false on clickCheck.

Then the ternary operator runs false code to get answer data so simple.



I hope you read my article Build own quiz app.

Any suggestions and issues plz tell me to feel free.