Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

130
Visualizações
Redirecting issue with react-router-dom

I'm having an issue with react router dom, Every time I click the sign in button that should take me to Chat.js but instead it just updates the link not the page.

Here’s my code in App.js

<Router> 
<Route exact path="/" component={Join}/> 
<Route path="/chat" component={Chat}/> 
</Router>

And in Join.js

import React, { useState } from "react";
import {Link} from "react-router-dom"

import "./Join.css"

function Join() {
    const [name, setName] = useState()
    const [room, setRoom] = useState()
    return (
        <div className="joinOuterContainer">
            <div className="joinInnerContainer">
            <h1 className="heading">Join</h1>
                <div><input className="joinInput" type="text" placeholder="Name" onChange={(e) => setName(e.target.value)}/></div>
                <div><input className="joinInput mt-20" type="text" placeholder="Room" onChange={(e) => setRoom(e.target.value)}/></div>
        
                <Link to={`/chat?name=${name}&room=${room}`}>
                    <button type="submit" className="button mt-20">Sign In</button>
                </Link>
            </div>
        </div>
    )
}

export default Join

I thought about adding arrow heads between the components i.e. {<Chat/>} and replacing component with element but it just won't work.. any thoughts on how to fix this?

Note: I'm using react v18 and react-router-dom v5

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You should use a higher level router such as BrowserRouter. https://reactrouter.com/docs/en/v6/api#router

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda