Skip to content

Instantly share code, notes, and snippets.

@jakesorce
Created May 5, 2017 22:30
Show Gist options
  • Save jakesorce/12fba24221be3781f29c6821f962830a to your computer and use it in GitHub Desktop.
Save jakesorce/12fba24221be3781f29c6821f962830a to your computer and use it in GitHub Desktop.
import React from 'react';
import Player from './Player';
import Game from './Game';
class Yahtzee extends React.Component {
state = { name: '', edit: true }
updatePlayer = (name) => {
this.setState({ name, edit: false })
}
editPlayer = () => {
this.setState({ edit: true });
}
render() {
let { state: { name, edit }, updatePlayer, editPlayer } = this;
return (
<div>
{ edit ?
<Player handleSubmit={updatePlayer} name={name} />
:
<Game player={name} editPlayer={editPlayer} />
}
</div>
)
}
}
export default Yahtzee;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment