- Begin by creating a new React app
- Go to empty folder, open VS Code terminal
- npx create-react-app pso-07
- cd pso-07
- In App.js, clear out existing code except for the div and add a function - login(username,password)
- Create a components folder
- Add a login form component - LoginForm.js
- Import this login form to App.js, and add it between the div tags, passing the login function as a prop
In LoginForm.js
- Create a login form with the basic stuff - username, password, login button
- Import the useState hook and add state to the login form
- Create state variables to hold the username and password
- Create functions to handle changes to the input fields
- Connect these functions to the respective input fields
- Create a handleSubmit() function and connect it to the form submit event
- Prevent the default action and instead use props to call the login function present in App.js
- In App.js, console log the username and password