react-router icon indicating copy to clipboard operation
react-router copied to clipboard

Dynamic routing vs absolute path in root

Open ricardosoeiro opened this issue 11 years ago • 2 comments

Hi,

The root url of my app is something like "localhost/MyApp/". I'm trying to set up dynamic routing using plain routes, but I'm unable to set the path of my root route to /MyApp/. Is this a suported scenario?

Sample code:

var childRoutes = [{ 
 <Route path="About" component="About" /> },
 <Route path="Home" component="Home" /> } 
}];

var routes = {
    path: "/MyApp/",
    component: Root,
    getChildRoutes: (location, callback) => {
        callback(null, childRoutes);
    }   
}
ReactDOM.render(<Router>{routes}</Router>), reactContainer);

In this example, getChildRoutes is never called, unless I change the root path from "/MyApp/" to "/". But in this case, I'm matching the root path of my server which is NOT what I want to achieve, because all my app components live inside /MyApp/. Is there a workaround for this scenario?

Cheers

ricardosoeiro avatar Sep 20 '15 23:09 ricardosoeiro

Basename Support is probably what you are looking for! :)

edvinerikson avatar Sep 25 '15 18:09 edvinerikson

thanks for the answer @edvinerikson

knowbody avatar Oct 06 '15 05:10 knowbody