I have the following react-router configuration
import React from 'react'
import { BrowserRouter, Route } from 'react-router-dom'
<BrowserRouter>
<Route exact path='/sign-in' component={SignIn} />
<Route exact path='/:username' component={Profile} />
</BrowserRouter>
When on a profile page like /dylan
the Profile component matches and :username param is "dylan" like I would expect.
When navigating to the /sign-in
route, the component gets rendered and the component get rendered too (with sign-in
as the username)
What is the idiomatic solution with react-router v4 to prevent routes from matching multiple components?
versions:
- react-router-dom 4.1.2
<Switch>
component – azium