Created
February 23, 2018 09:39
-
-
Save borlaym/a21d1edd217b0207587e62cc2fb3966c to your computer and use it in GitHub Desktop.
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
// components/Attribute.js | |
function Attribute(props) { | |
return ( | |
<div> | |
<a onClick={props.onClick}> | |
{props.name} | |
</a> | |
</div> | |
); | |
} | |
// components/Sheet.js | |
function Sheet(props) { | |
return ( | |
<div> | |
<Attribute name="Strength" value={props.strength} onClick={() => props.onChange('strength')} /> | |
<Attribute name="Agility" value={props.agility} onClick={() => props.onChange('agility')} /> | |
</div> | |
); | |
} | |
// index.js | |
const char = new Character(); | |
function changeAttribute(attrName) { | |
char.changeAttribute(attrName); | |
render(); | |
} | |
function render() { | |
ReactDOM.render(<Sheet | |
strength={char.strength} | |
agility={char.agility} | |
onChange={char.changeAttribute} | |
/>); | |
} | |
render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment