In a componentDidUpdate
lifecycle method you could serialize the state:
componentDidUpdate: function(prevProps, prevState) {
localStorage.state = JSON.stringify(this.state);
}
That code will be run each time the component rerenders (which happens with every props or state change).