Created
October 26, 2018 01:07
-
-
Save mikehibm/3d0936fc988a1897a7c2ecb8b792c1cd to your computer and use it in GitHub Desktop.
App.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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