Skip to content

Purdue-WDC/pso-07

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSO Lecture 07 - React State & Hooks

  1. Begin by creating a new React app
  2. Go to empty folder, open VS Code terminal
    • npx create-react-app pso-07
    • cd pso-07
  3. In App.js, clear out existing code except for the div and add a function - login(username,password)
  4. Create a components folder
  5. Add a login form component - LoginForm.js
  6. Import this login form to App.js, and add it between the div tags, passing the login function as a prop

In LoginForm.js

  1. Create a login form with the basic stuff - username, password, login button
  2. Import the useState hook and add state to the login form
  3. Create state variables to hold the username and password
  4. Create functions to handle changes to the input fields
  5. Connect these functions to the respective input fields
  6. Create a handleSubmit() function and connect it to the form submit event
  7. Prevent the default action and instead use props to call the login function present in App.js
  8. In App.js, console log the username and password

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published