Created
May 4, 2015 19:51
-
-
Save anonymous/f86840758f7be6bb971b to your computer and use it in GitHub Desktop.
evented JSX rendering without classes
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
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