Create a Quiz App using ReactJS
Start a project by the following command –
npx create-react-app quiz
NPX is a package runner tool that comes with npm 5.2+, npx is easy to use CLI tools. npx is used for executing Node packages. It greatly simplifies a number of things one of which is checked/run a node package quickly without installing it locally or globally.
now, goto the folder create
Start the server- Start the server by typing following command in terminal –
Change directory to src –
Delete every thing inside the directory
This file will render our app to html file which is in public folder now, create a folder name components with files src/components/QuestionBox.js and src/components/ResultBox.js to hold our app components and a folder question with file src/question/index.js to hold our questions.
mkdir components && cd components && touch app.js
mkdir question && cd question && index.js
Edit src/index.js file
This file contains our app logic.
Edit src/question/index.js file: This file contains all question which will be displayed.
Edit src/components/QuestionBox.js file: This file makes question box with buttons.
Edit src/components/ResultBox.js file: This file displays the result.
Save all files and start the server:
open http://localhost:3000/ URL in the browser. It will display the result.