Redirect to homepage once user registers

This commit is contained in:
Ray 2023-09-19 10:58:05 +00:00 committed by GitHub
parent b682d93e92
commit 892df52755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import Col from 'react-bootstrap/Col';
import Button from "react-bootstrap/Button";
import {useState, useEffect, useContext} from 'react';
import { AuthContext } from "../contexts/AuthContext";
import {useNavigate} from 'react-router-dom';
export function Signup ( props ) {
const[username,setUsername] = useState('')
@ -21,6 +22,14 @@ export function Signup ( props ) {
props.handler( useremail, userpassword )
}
const navigate = useNavigate()
useEffect( () => {
if( auth ) {
// go to home page
navigate("/")
}
}, [auth])
useEffect( () => {
if( username.length >= 4 ) {
setValidusername(true)
@ -93,4 +102,4 @@ export function Signup ( props ) {
</Row>
</Container>
)
}
}