Answer the question
In order to leave comments, you need to log in
Why is react router rerendering the whole app?
There is an app file
import React from 'react'
import Header from './Header'
import Main from './Main'
const App = () => (
<div>
<Header />
<Main />
</div>
)
export default App;
import React from 'react'
import { Link } from 'react-router-dom'
const Header = () => (
<header>
<nav>
<ul>
<li><Link to='/'>Home</Link></li>
<li><Link to='/Profile'>Profile</Link></li>
</ul>
</nav>
</header>
)
export default Header
import React from 'react'
import { Switch, Route } from 'react-router-dom'
import Home from './Home'
import Profilefrom './Profile'
const Main = () => (
<main>
<Switch>
<Route exact path='/' component={Home}/>
<Route path='/profile' component={Profile}/>
</Switch>
</main>
)
export default Main
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question