Skip to content

Instantly share code, notes, and snippets.

@leebyron
Last active August 29, 2015 14:08
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 leebyron/272a37e963978ba77a6c to your computer and use it in GitHub Desktop.
Save leebyron/272a37e963978ba77a6c to your computer and use it in GitHub Desktop.
function handleClick(element, event) {
if (event.button === 1) {
return { count: 0 };
}
if (element.props.onClick) {
element.onClick();
}
element.updateState(s => {...s, count: s.count + 1 });
}
export function render(element) {
return (
<div>
Clicked {element.state.count} times
<button onClick={handleClick} style={{ width: element.props.width }} />
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment