October 2019
Intermediate to advanced
426 pages
11h 49m
English
For registration, we are additionally going to check whether the entered passwords are the same, and only then will we set the user value.
Let's start by modifying the Register component in order to make it dynamic:
import React, { useState } from 'react'export default function Register ({ setUser }) { const [ username, setUsername ] = useState('') function handleUsername (evt) { setUsername(evt.target.value) } return ( <form onSubmit={e => { e.preventDefault(); setUser(username) }}> <label htmlFor="register-username">Username:</label> <input type="text" value={username} onChange={handleUsername} name="register-username" id="register-username" ...Read now
Unlock full access