React.js and browser history: a history.js mixin
So you’ve written a snazzy interface using React and you’re pretty happy with it, but while playing around with it you hit your browser’s back-button, and
suddenly you’re on a completely different page, huh?
The problem is that although React is updating and keeping track of its state
internally, this information is never communicated to the browser, and so the
browser has no concept of what state your React components are in.
To mitigate this I have written a mixin for use with
history.js which allows you to
save the current state of your UI in the browser’s history, and that way allow
you to navigate back and forth in the state of your application (
an impressive piece of software, which makes manipulating the browser history a
breeze, without it I would never have been able to write this).
Simple working example #
Here’s very simple example of using mixin
Continue reading →