Hello-World-Software-Studios / calculator

Carpenter's tool for wall layout
0 stars 1 forks source link

Make username and password persist over renders #51

Closed ecumene closed 3 years ago

ecumene commented 3 years ago
JPM709 commented 3 years ago

user information is now in useState:

const [userInformation, setUserInformation] = useState({
    username: "",
    password: "",
  });

onChange functions now use setUserInformation:

 const onChangeName = (event) => {
    setUserInformation((prevState) => ({
      username: event.target.value,
      password: prevState.password,
    }));
  };
  const onChangePassword = (event) => {
    setUserInformation((prevState) => ({
      username: prevState.username,
      password: event.target.value,
    }));
  };