This week's project is to use React to build a survey form ⚛ . This project should consist of at least 3 questions that need to be answered by users. When the user presses submit, they should see a summary of their answers.
Before I started to code I decided what question I wanted to ask in the survey. After that I clarified the logic, I added the questions in different components and defined the states for each question in the Form.js component. I rendered all the questions and added some styling to the page. When I was done with the “core” of the survey I started to code the more advanced features:
- Show different components
- Show a summary of the user’s submissions
I had some problems understanding how to make it work. I solved it by asking my team members, my teacher during a one to one and looking through stackoverflow.
With this help I could manage to understand how to make every component on a separate page with the if else statement and add the function to the onSubmit. I also managed to send the value from the states in Form.js and add it to the summary component with props.
- React
- JSX
- useState
- JavaScript
- CSS