Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!