Last active
January 3, 2018 18:15
-
-
Save StoneCypher/96e2c147694bddb91c98 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
// this is the react app. it knows nothing of the vanilla app, other than that the information | |
// will come in in props, and that it should call this hook when this button is pressed, or etc | |
var Spinner = (props) => | |
<div> | |
{this.props.data} | |
<button value="↑" onclick={this.props.hooks.inc}/> | |
<button value="↓" onclick={this.props.hooks.dec}/> | |
</div>; | |
export {Spinner}; |
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
import {Spinner} from './brainless_renderer.js'; | |
// this is a vanilla js app. it knows nothing of react, other than | |
// to call `.render` on line 9 with relevant data and callbacks. | |
var App = function() { | |
var repaint = () => ReactDOM.render(document.body, <Spinner data={counter} hooks={hooks}/>), | |
counter = 0, | |
inc = () => { ++counter; repaint() }, | |
dec = () => { --counter; repaint() }, | |
hooks = {inc, dec}; | |
return { | |
value: () => counter, | |
inc, | |
dec, | |
repaint | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment