Reactjs with history
It's not too much different than how you would handle history without React.js. What works well for me is this: I have a top-level component that holds the state of the app in this.state
. I'm using Backbone's router, so when I get an event from the router (a URL was loaded or changed in some way), I call setState
to update the top-level component's state. When I update the state myself, I make sure to also call the router's navigate method to update the URL. Seems to work pretty well: you can see an example from my little app at https://github.com/mjm/eats.
In the React distribution there's an exemple folder with one being TodoMVC + Director.
Flatiron Director is a router, so you'll have an exemple on how to use it in React.
Notice that Instagram is currently using Backbone router but they are planning to use Director (mostly because they can use the same router on client and server side and they don't need Backbone except the router)
Another option with React is to use the React router component. It handles pushState for you and you can dynamically change the available routes as needed. It works with the same methodology as React does, as it is a react class itself. Check it out at:
https://www.npmjs.org/package/react-router-component