Skip to content

Instantly share code, notes, and snippets.

@drenther
Last active March 5, 2019 20:25
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 drenther/8d67f7614c61f78c8517ae83e8199e75 to your computer and use it in GitHub Desktop.
Save drenther/8d67f7614c61f78c8517ae83e8199e75 to your computer and use it in GitHub Desktop.
The App component render function
class App extends React.Component {
render() {
const { gameState, timeLeft, bench, ...groups } = this.state;
const isDropDisabled = gameState === GAME_STATE.DONE;
return (
<>
<Header gameState={gameState} timeLeft={timeLeft} endGame={this.endGame} />
{this.state.gameState !== GAME_STATE.PLAYING && (
<Modal
startGame={this.startGame}
resetGame={this.resetGame}
timeLeft={timeLeft}
gameState={gameState}
groups={groups}
/>
)}
{(this.state.gameState === GAME_STATE.PLAYING ||
this.state.gameState === GAME_STATE.DONE) && (
<DragDropContext onDragEnd={this.onDragEnd}>
<div className="container">
<div className="columns">
<Dropzone
id={COMICS.MARVEL}
heroes={this.state[COMICS.MARVEL]}
isDropDisabled={isDropDisabled}
/>
<Dropzone id="bench" heroes={bench} isDropDisabled={isDropDisabled} />
<Dropzone
id={COMICS.DC}
heroes={this.state[COMICS.DC]}
isDropDisabled={isDropDisabled}
/>
</div>
</div>
</DragDropContext>
)}
<Footer />
</>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment