I am creating a registration box and when I click on login/register I need to go to another route but it doesn't happen, what's the problem? Added the full code of the registration page. In utils/consts, the routes are declared, which I have given below. What else could be the problem?
import React from 'react';
import {Button, Card, Container, Form, NavLink, Row} from "react-bootstrap";
import {LOGIN_ROUTE, REGISTRATION_ROUTE} from "../utlis/consts";
import {useLocation} from "react-router-dom";
const Auth = () => {
const location = useLocation();
const isLogin = location.pathname === LOGIN_ROUTE;
console.log(location);
return (
<Container
className="d-flex justify-content-center align-items-center"
style={{height:window.innerHeight - 54}}
>
<Card style={{width: 600}} className="p-5">
<h2 className="m-auto">{isLogin ? 'Авторизация' : "Регистрация"}</h2>
<Form className="d-flex flex-column">
<Form.Control
className="mt-3"
placeholder="Enter your email..."
/>
<Form.Control
className="mt-3"
placeholder="Enter you password..."
/>
<Row className="d-flex justify-content-between mt-3 pl-3 pr-3">
{isLogin ?
<div>
Don't have an account?<NavLink to={REGISTRATION_ROUTE}>Register!</NavLink>
</div>
:
<div>
Have an account?<NavLink to={LOGIN_ROUTE}>Login!</NavLink>
</div>
}
<Button
variant={"outline-success"}
>
{isLogin ? 'Login' : 'Registration'}
</Button>
</Row>
Paths to constants are registered:
export const LOGIN_ROUTE = '/login'
export const REGISTRATION_ROUTE = '/registration'