Created
July 7, 2019 19:24
-
-
Save ezekielchentnik/ed64f499295e4c08fc19e594c76230f2 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
var createView = function(update) { | |
var increase = function(amount) { | |
return function(_event) { | |
update(amount); | |
}; | |
}; | |
var view = function(model) { | |
return (<div> | |
<div>Counter: {model}</div> | |
<button onClick={increase( 1)}>+1</button> | |
<button onClick={increase(-1)}>-1</button> | |
</div>); | |
}; | |
return view; | |
}; | |
var model = 0; | |
var element = document.getElementById("app"); | |
var view = null; | |
var update = function(value) { | |
model = model + value; | |
ReactDOM.render(view(model), element); | |
}; | |
view = createView(update); | |
ReactDOM.render(view(model), element); | |
this.setState(function (state, props) { | |
return { | |
score: state.score - 1 | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment