Skip to content

Instantly share code, notes, and snippets.

@borlaym
Created February 23, 2018 09:39
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 borlaym/a21d1edd217b0207587e62cc2fb3966c to your computer and use it in GitHub Desktop.
Save borlaym/a21d1edd217b0207587e62cc2fb3966c to your computer and use it in GitHub Desktop.
// 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