scripton
scripton

Reputation: 246

react-router 2.0: # support in configuration

I upgraded from react-router 0.13.x to 2.0. I noticed that react-router is no longer rendering the hashtag inside the urls. As a result, my routes aren't working anymore when directly visited.

If I try to place the hashtag directly in my configuration, it fails to match the url. How can I get react-router to render the hashtags? It used to do this by default in version 0.13.x.

render((
    <Router history={browserHistory}>
        <Route path="/" component={App}>
                <Route name="foo" path="/foo" component={Foo}/>
                <Route name="bar" path="/bar" component={Bar}/>
            </Route>
        </Route>
    </Router>
), document.getElementById('app'));

Upvotes: 0

Views: 135

Answers (1)

JulienD
JulienD

Reputation: 7293

Remove the hashtag from path, this looks horrible. Your browserHistory needs to be a hashHistory instead. It was the default to have a hashHistory before, now you need to specify it.

Also routes don't have a name anymore, and path uses no slash if you want to nest it in the /web/dist route. You should read the guide carefully again.

Upvotes: 3

Related Questions