Skip to content

Instantly share code, notes, and snippets.

@jacobp100
Created March 23, 2018 21:48
Show Gist options
  • Select an option

  • Save jacobp100/7b55202fec3de322433f06e0475634ab to your computer and use it in GitHub Desktop.

Select an option

Save jacobp100/7b55202fec3de322433f06e0475634ab to your computer and use it in GitHub Desktop.
class LoaderWithGame extends React.Component {
state = { isPlaying: false }
startGame = () => this.setState({ isPlaying: true })
endGame = () => this.setState({ isPlaying: false })
render() {
return (
<React.Timeout>
{didTimeout => (
<React.Fragment>
{(didTimeout || this.state.isPlaying) && (
<LoadingGame
onStart={this.startGame}
onEnd={this.endGame}
/>
)}
{!didTimeout && <MainContent />}
</React.Fragment>
)}
</React.Timeout>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment