I'm using react router to navigate through my application, but I don't want react router to make a call to the server, is that possible?
1 Answer
You should use Hash history.
import { Router, Route } from 'react-router'
import createHashHistory from 'history/lib/createHashHistory'
<Router history={ createHashHistory({ queryKey: false }) }>
<Route path="/" component={App} />
</Router>
If you don't want to use the hash history (which appends a # to the url), use the Link Component which will correctly navigate the App based on the history type passed.
location.hrefdirectly, you will hit the server, but if you usebrowserHistory.push(), it will not. That said, if you hit a route directly (i.e. type the address and hit enter). It will hit your server. in that case, you need your server to serve upindex.html. See github.com/reactjs/react-router/blob/master/docs/guides/…