Skip to content

Instantly share code, notes, and snippets.

Created May 4, 2015 19:51
Show Gist options
  • Save anonymous/f86840758f7be6bb971b to your computer and use it in GitHub Desktop.
Save anonymous/f86840758f7be6bb971b to your computer and use it in GitHub Desktop.
evented JSX rendering without classes
function siteDef(state) {
return <div>
function* () {
var state = "Your Site";
var resolve;
function render() {
return <h1 contentEditable={true} onInput={onInput}>{state}</h1>;
}
function rerender() {
resolve(render())
}
function onInput(event) {
state = event.target.innerHTML;
rerender()
}
yield render()
while (true) {
yield new Promise(function(_resolve, reject) {
resolve = _resolve;
});
}
}
<div>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment