DEV Community

Cover image for Build a Flashcard quiz with React
Gbadebo ifedayo
Gbadebo ifedayo

Posted on • Edited on

7 1

Build a Flashcard quiz with React

Welcome, today we're going to make a react flashcard quiz with React.js.

First, launch your terminal and use the create react-app command to create our new React app.


Next, we open up our project in our code editor and and remove unnecessary code in the App.js file.
Image description
Next, we import React and make an array questions_list with our test questions in it. Then we develop Flashcard.js and Flashcardlist.js files in the src folder to store project-related components.


The structure of our flashcards is generated next by going to Flashcard.js. We create a function component and give it a props "card" to achieve this. When a flashcard is clicked, the card flip concept is used to reveal the answer. We import useState in order to achieve this.


In Flashcardlist.js, we import the Flashcard component and construct a list of flashcards, passing our Flashcard prop card to each element of the flashcards array.


After navigating to App.js, we import the useState hook and our flashcardlist component. We create a state variable array and assign it to the questions_list array.The array list is then passed as flashcards props to the Flashcardlist component.


The styles for our flashcards are then stored in a Flashcard.css file that is created next. In Flashcard.js, this file has been imported.


After finishing our quick flashcard app using React, feel free to add more questions to the list to make it more interesting. Here is the URL of the github repository.

Image description

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

Best practices for optimal infrastructure performance with Magento

Running a Magento store? Struggling with performance bottlenecks? Join us and get actionable insights and real-world strategies to keep your store fast and reliable.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️