I am trying to figure out why if let’s say I am in the middle of the route/page /current-path
, if I go to /new-path
, then /new-path
loads just in the middle or in the same position where I left the old path. The regular behavior should be if I go to a new route, the new route/page should load from the top.
I recorded a video for you to see what I talk about.
If you see, in the video I go to a new route and if I want to go to the top, I have to scroll to it.
This is the component where I have my routes:
import { BrowserRouter as Router, Route, Link, Switch } from 'react-router-dom';
// … rest of the imports here
const App = () => (
<ReduxProvider store={reduxStore}>
<Router>
<div className="App">
<div className="App-container">
<Switch>
<Route path="/applications" component={Applications} />
<Route path="/terms" component={Terms} />
<Route path="/signup" component={SignupPage} />
<Route path="/choose-profile" component={ChooseProfile} />
<Route path="/profile-completion" component={ProfileCompletion} />
<Route path="/investor-personal-profile" component={InvestorProfile} />
<Route path="/startup-application" component={StartupApplication} />
<Route path="/investor-application" component={InvestorApplication} />
<Route exact path="/startup/:startup" component={StartupProfile} />
<Route path="/search" component={SearchStartup} />
<Route exact path="/investor/search" component={SearchProfile} />
<Route path="/wiretransfer-instructions" component={WireTransfer} />
<Route exact path="/about-us" component={AboutUs} />
<Route exact path="/how-it-works" component={HowItWorks} />
<Route exact path="/faq" component={Faqs} />
<Route exact path="/:startup" component={StartupPublicProfile} />
<Route path="/" component={HomePage} />
</Switch>
</div>
</div>
<Footer />
</Router>
</ReduxProvider>
);
export default App;
I already tried to go to a new route with the Link
component of react router, <Link to="/about-us">About Us</Link>
and also like this =>
<button onClick={() => history.push('/faq')}>
FAQ and Guides
</button>
So what could I be doing wrong?