V
V
Vanyag2021-04-26 10:47:26
React
Vanyag, 2021-04-26 10:47:26

How to make it so that after filling out the form and clicking on the button, it goes to login?

import { func } from "prop-types";
import React, { useState } from "react";
import {useDispatch} from 'react-redux';
import ReactDOM from 'react-dom';
import {useHistory} from 'react-router-dom'

// Import registration operation;
import Login from "./Login";

export default function Form() {
const [firstName, setFirstName] = useState("");
const [lastName, setLastName] = useState("");
const [phone, setPhone] = useState("");
const [submitted, setSubmitted] = useState(false);

const dispatch = useDispatch();



const onRegister = (user) => {
console. log("registered " +user);
};

const handleChange = (event) => {
const { value, name } = event.target;

console.log(event.target.value);
switch (name) {
case "firstname":
setFirstName(value);
return;
case "lastname":
setLastName(value);
return;
case "phone":
setPhone(value);
default:
console.warn("Please check the input");
}
console.log(submitted);
};

const handleSubmit = (evt) => {
evt.preventDefault();

const user = {
firstName,
lastName,
phone,
};
console log(user);
// dispatch(call the imported operation and pass the user into it)

ReactDOM.render(, document.querySelector(".App"));
};

return (

handleSubmit(evt)}>
value={firstName}
name="firstname"
type="text"
onChange={(evt) => handleChange(evt)}
placeholder="Enter your name"
required
/>
value={lastName }
name="lastname"
type="text"
onChange={(evt) => handleChange(evt)}
placeholder="
required
/>
value={phone}
name="phone"
type="text"
onChange={(evt) => handleChange(evt)}
placeholder="Enter your phone number "
/>
Continue


);
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question