Skip to content

Instantly share code, notes, and snippets.

@mikehibm
Created October 26, 2018 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikehibm/3d0936fc988a1897a7c2ecb8b792c1cd to your computer and use it in GitHub Desktop.
Save mikehibm/3d0936fc988a1897a7c2ecb8b792c1cd to your computer and use it in GitHub Desktop.
App.tsx
class App extends React.Component<Props, State> {
state = { page: 'menu' };
onChangeStore = () => {
const { page } = store.getState();
this.setState({ page });
};
componentDidMount() {
store.on('page_changed', this.onChangeStore);
}
componentWillUnmount() {
store.off('page_changed', this.onChangeStore);
}
public render() {
const { page } = this.state;
return (
<div className="App">
<header className="App-header">
<h1 className="App-title">Reversi</h1>
</header>
{page === 'menu' ? <Menu /> : <Game />}
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment