Home > database >  How do i display a page/component once In React Js
How do i display a page/component once In React Js

Time:07-08

So I just got my first job as a react developer and I was asked to create a one time page for users to answer some questions (like a form) and after the users have answered all the questions and submitted the question page shouldn't come up again.

I have created the page for the questions. But I have no idea on how to display the page only once

Can someone please help me out. I'll really appreciate.. Thanks

CodePudding user response:

You need a backend for storing the user data, and a field in the database that will be equal to 0 or 1, if the user doesn't answer the question will be equal to 0 if he answers will be equal to 1.

CodePudding user response:

If you want to switch between pages (like, whole pages, url and all), you may find useful to check the library React-router. react-router is a library that helps you switch between different pages, and you can put any logic you want in it, for selecting the pages you want to display.

You probably will need to save and retrieve your state to find out when to show the correct page. And for that, one way could be using Redux, and storing your global state in localStorage. I'll leave the docs for Redux too below. Hope this helps!

resources:

  • Related