Last active
August 29, 2015 14:15
-
-
Save wmertens/4aeb05dfffd77db57351 to your computer and use it in GitHub Desktop.
PwRggP
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
# Pure coffeescript React.JS | |
# Also features "global state manager" | |
R = React.DOM | |
N = null | |
# global state manager | |
render = null | |
state = clicks: 0 | |
count = -> | |
state.clicks++ | |
render() | |
Hello = React.createClass | |
shouldComponentUpdate: (props) -> | |
props.clicks isnt @props.clicks | |
componentDidMount: -> | |
console.log "new element" | |
count: -> | |
count() | |
render: -> | |
R.div N, "Hello #{@props.name}", | |
R.p N, "How are you?" | |
R.button onClick: @count, "Click me" | |
R.p N, """ | |
Clicked #{@props.clicks} time#{if @props.clicks != 1 then "s" else ""}. | |
""" | |
render = -> | |
React.renderComponent Hello(name:"World", clicks:state.clicks), document.body | |
render() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment