F
F
Flip22020-05-28 15:39:12
React
Flip2, 2020-05-28 15:39:12

Why can't I open the page by url?

I set up routing, the url changes, but when I want to enter it, the main page opens and nothing happens. What could be the reason?

<BrowserRouter>
   <Link to='/sign_up'>Сlick me</Link>
   <Route path='/sign_up' component={Example} />
</ BrowserRouter>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alex4answ, 2020-05-28
@alex4answ

Route must be children of Switch

Y
yaroslav1996, 2020-05-28
@yaroslav1996

<BrowserRouter>
<Link to='/sign_up'>Сlick me</Link>
<Switch>
<Route path='/' exact render={() => <h1>Home</h1>} />
<Route path='/sign_up' component={Example} />
</Switch>
</BrowserRouter>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question