For this project we were tasked to build a survey using React and practice using React useState hook. We had free reign to choose what our survey should be about, but we were asked to fill the basic requirements:
- The survey should consist of at least 3 questions.
- At least one question should consist of radio buttons and the select dropdown.
- There should be a submit button, which when pressed should hide the form and reveal a summary of the data inputted by the user.
- The site should follow accessibility guidelines.
- Used React to create different components and the useState hook to submit data inputted by the user and render components dynamically depending if the state is true or false.
- Store data inputted by user using useState and use useState to render components dynamically depending if the state is true or false based on if the user has submitted the specific form or not.
- Pass data inputted by the user into the different components rendered via props. With all the data inputted sent to the Summary.js component to render all data inputted by the user.
- Used text input, radio buttons(custom), checkboxes(custom) and dropdown input for different questions.
- Use onClick event for home button to navigate the user back to the homepage.
- Use map method to map through array elements and return a new array of the elements for specifc JSX, used for example on the array of craft beer types.
- Implemented basic accessibility for users who use screen readers and keyboards. This includes using semantic HTML, aria-labels and tab-index.
- Used React tooltip library as I was having issues with the required input attribute not showing a message if the user tries to go to the next question before selecting an option from the form. The tooltip gives the user a specific message asking them to take an action.
- I also had to use React useRef hook and the JavaScript focus() method to focus on the input. This was because when the user is using the keyboard to navigate using the tab key and enters a new form the "next question" button is focused on. Targeting the JSX for the form using the useRef in combination with the JavaScript focus() method in the useEffect before the component is mounted allows for the form to be the first thing focused.
- Styled the page and made it responsive for mobile, tablet and desktop.
- NPM package manager.
- The React starter App that cam included in this project repo.
- Package.json.
- JavaScript, React.js, React useState and useRef hook.
- React tooltip.
- CSS.
- Googaling, Technigo videos and lectures.