Chris
Chris

Reputation: 391

hashHistory not working

I have React Project and the react-router structure is as follows

var routes = (
    <Route path="/" component={ App }>
      <IndexRoute component={ Greeting }/>
      <Route path="user/:user_id" component={ Profile }>
      </Route>
      <Route path="playlists" component={PlaylistIndex}/>
      <Route path="playlists/:playlist_id" component={SinglePlaylist}/>
      <Route path="songs" component={SongIndex}/>
      <Route path="songs/:song_id" component={SingleSong}/>
    </Route>
);

document.addEventListener("DOMContentLoaded", function () {
  var container = document.getElementById("root");
  Modal.setAppElement(container);
  ReactDOM.render(
    <Router history={hashHistory}>{routes}</Router>,
    container
  );
});

However if I try to refresh or go to a page using a path it should have IE localhost:3000/user/1 it does not load the component it should. It worked fine with an older version of react-router when it had a default history prop built in, but now that react-router has gone through some updates I am required to use hashHistory as a prop, but it does not seem to work the same. Any help would be phenomenal!

Upvotes: 0

Views: 1079

Answers (1)

Wylliam Judd
Wylliam Judd

Reputation: 10905

Hash history uses a #. It should look like this: localhost/#/user/1

Upvotes: 1

Related Questions