For a Quiz to function properly, we need to have questions and answers. In the previous tutorial, we create the main React Component Quiz
. We will learn, in this tutorial, how to create a Question
and Answer
Component.
Building a Quiz with React and WordPress REST API: Quiz Component
The main Component of our React Quiz will be the Quiz Component. In the last tutorial, we have integrated the React WP Scripts into our plugin. Now, we are going to move forward by changing the files and adding new ones.
Building a Quiz with React and WordPress REST API: React WP Scripts Tool
To create a Quiz with React, we need to configure our scripts that will compile modern JavaScript (ESNext) and JSX. We could go into and construct everything on our own or we can use tools that already exist. In this tutorial, we will see how to use the react-wp-scripts by Human Made.
Building a Quiz with React and WordPress REST API: CPT and REST API Routes
We will use the WordPress REST API Routes to retrieve questions and scores used for building our Quiz in React. We need a route to retrieve the questions with their answers and to submit the answers so we can get our result. In this tutorial, we will proceed to our WordPress roadmap and define our custom post type, metabox and also the WordPress REST API Routes.
Building a Quiz with React and WordPress REST API: Introduction
Quizzes are really popular in WordPress and many of them include steps. Using React, we are going to build a simple quiz with JavaScript that will render one question per time. Let’s learn how to use React and connect with the WordPress REST API to manage the answers and questions.