React Router Default Route Redirect To /home
I am very new to react and and the router and bootstrap libraries I chose to use. They are basically just react-router-bootstrap. I am just getting a feel for things and I want t
Solution 1:
The only change that I made was to your routes, they used to look like this:
var routes = (
<Routehandler={App} ><DefaultRoutehandler={Home}/><Routename="home"handler={Home}path="/home"></Route><Routename="browse"handler={Browse}path="/browse"></Route><Routename="add"handler={Add}path="/add"></Route><Routename="about"handler={About}path="/about"></Route></Route>
);
and I changed them to this:
var routes = (
<Routehandler={App} ><DefaultRoutename="home"path="/"handler={Home}/><Routehandler={Home}path="/home"></Route><Routename="browse"handler={Browse}path="/browse"></Route><Routename="add"handler={Add}path="/add"></Route><Routename="about"handler={About}path="/about"></Route></Route>
);
I tested it and it works as expected. When you visit the home page the url only has the /#/
and is not suffixed like /#/home
, I don't think that is an issue.
Post a Comment for "React Router Default Route Redirect To /home"