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

842
Views
React-Router: No routes matched location, but still works?

I keep getting an annoying console.log(router.ts:11 No routes matched location "/user/root") for example.

My application for now is incredibly simple. If a user is logged in, i return these routes available.

return (
  <Routes>
   <Route path={`/user/:username`} element={<User/>}/>
  </Routes>
)

The <User/> component simply returns either "your account" , or "other account" depending on what the route username the user types in the browser is.

const User = () => {
    const username = useParams().username
    if (username === 'root'){
        return <h1>your account</h1>
    }
    return (
        <h1>other user</h1>
    )
}

The functionality works, and it displays correctly depending on the route typed in. However the No routes matched location "/user/root" console.log is driving me nuts. What am I doing wrong?

This is my App.js if needed for context

function App() {
  const user = useSelector(state => state.user)
  const dispatch = useDispatch()
  const navigate = useNavigate()
  // Checks if local storage saved user
  useEffect(() => {
    const loggedUserJSON = window.localStorage.getItem('loggedUser')
    if (loggedUserJSON) {
      const user= JSON.parse(loggedUserJSON)
      dispatch(loginUser(user))
    }
  }, [])

  const handleLogout = () => {
    dispatch(logoutUser())
  }

  // If no user in storage or store, display and redirect to login
  if (!user) {
    return (
      <Routes> 
        <Route path="/login" element={<Login/>}/>
        <Route path="/" element={<Home/>}/>
      </Routes>
    );
  }
 
  // If user found in store or local storage, send to their account profile
  return (
    <>
    <p>{user.user.username} signed in <button onClick={handleLogout}>logout</button></p>
    <Routes>
      <Route exact path={`/user/:username`} element={<User/>}/>
      <Route path={`/store`} element={<Home/>}/>
    </Routes>
    </>  
  )
}
about 4 years ago · Juan Pablo Isaza
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!