Skip to content

Instantly share code, notes, and snippets.

@arqex
Last active May 13, 2017 16:26
Show Gist options
  • Save arqex/04b0727dbdb0613720376ac81bdcb0a4 to your computer and use it in GitHub Desktop.
Save arqex/04b0727dbdb0613720376ac81bdcb0a4 to your computer and use it in GitHub Desktop.
Rerender on update
// Our root component
class App extends React.Component {
constructor(){
super();
this.state = freezer.get();
}
render(){ /.../ }
componentDidUpdate(){
// Re-render on update
// Our UI will always synchronized with the state
freezer.on('update', nextState => {
this.setState( nextState );
});
}
}
// Anywhere in the app
// This will refresh the UI
freezer.get().me.set({name: 'Manuel'});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment