0

У меня есть роутинг, когда перехожу по оно добавляет к домену нужный путь, но не перенаправляет на страницу. Тоесть на какой был странице, такой и остался, но добавился путь с Link

import './Login.css'
import logo from './images-general/logo.svg'
import imgRel from './images-general/indexImg.png'
import { Swiper, SwiperSlide } from 'swiper/react'
import "swiper/css"
import "swiper/css/pagination"
import { Pagination, Autoplay } from "swiper"


import { Link, Routes, Route } from 'react-router-dom'
import HomePage from './pages/HomePage'
import RegisterPage from './pages/RegisterPage'

function Login() {
  return (
    <div className="Login">
          <Routes>
              <Route path="/home" component={HomePage}/>
              <Route path="/register" component={RegisterPage}/>
          </Routes>
        <div className="login-wrapper">
            <div className="login-left">
                <div className="login-container">
                  <div className="login-left-header">
                    <Link to="/login" className="login-logo">
                      <img src={logo} alt="logo"/>
                    </Link>
                  </div>
                  <div className="login-form">
                    <span className="login-form-title">Login</span>
                    <p>Sign in with your data that you entered during your registration.</p>
                    <div className="login-email">
                        <span>Email</span>
                        <input type="email" placeholder="name@example.com"/>
                    </div>
                    <div className="login-password">
                        <span>Password</span>
                        <input type="password" placeholder="min. 8 characters"/>
                    </div>
                    <div className="login-check">
                        <input id="check" type="checkbox" />
                        <label for="check" >Keep me logged in</label>
                    </div>
                    <button className="login-confirm">Login</button>
                    <div className="login-rel-pass">
                        <button className="login-forgot">Forgot password</button>
                        <span>Don’t have an account?
                            <Link to="/register" className="login-signUp">Sign Up</Link>
                        </span>
                    </div>
                  </div>
                </div>
            </div>

1 ответ 1

0

import { useHistory } from "react-router-dom"

const history = useHistory();

<Link
  className="login-signUp"
  onClick={(event) => {
    event.stopPropagation();
    history.push("/register");
  }}
>
  Sign Up
</Link>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.