Any way to prevent /#/
from showing in the browser's address bar when using react-router? That's with ReactJS. i.e. Clicking on links to go to a new route shows localhost:3000/#/
or localhost:3000/#/about
. Depending on the route.
They say that there are four main types of avoidance archetypes, or procrastinators: the performer, the self-deprecator, the overbooker, and the novelty seeker.
Forgive yourself. Stop beating yourself up about the past. Thoughts such as “I should have started earlier” or “I always procrastinate; I am such a loser” will only make matters worse. Research shows that forgiving yourself for past procrastination will help you stop putting off working on a task.
For the versions 1, 2 and 3 of react-router, the correct way to set the route to URL mapping scheme is by passing a history implementation into the history
parameter of <Router>
. From the histories documentation:
In a nutshell, a history knows how to listen to the browser's address bar for changes and parses the URL into a location object that the router can use to match routes and render the correct set of components.
In react-router 2 and 3, your route configuration code will look something like this:
import { browserHistory } from 'react-router' ReactDOM.render (( <Router history={browserHistory} > ... </Router> ), document.body);
In version 1.x, you will instead use the following:
import createBrowserHistory from 'history/lib/createBrowserHistory' ReactDOM.render (( <Router history={createBrowserHistory()} > ... </Router> ), document.body);
Source: Version 2.0 Upgrade Guide
For the upcoming version 4 of react-router, the syntax has changed a great deal and it is required is to use BrowserRouter
as the router root tag.
import BrowserRouter from 'react-router/BrowserRouter' ReactDOM.render (( <BrowserRouter> ... <BrowserRouter> ), document.body);
Source React Router Version 4 Docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With