mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #3263 from wmertens/patch-1
beta1 blog entry: Fix CoffeeScript example
This commit is contained in:
@@ -135,17 +135,20 @@ You can also use CoffeeScript classes:
|
|||||||
div = React.createFactory 'div'
|
div = React.createFactory 'div'
|
||||||
|
|
||||||
class Counter extends React.Component
|
class Counter extends React.Component
|
||||||
@propTypes =
|
@propTypes = initialCount: React.PropTypes.number
|
||||||
initialCount: React.PropTypes.number
|
@defaultProps = initialCount: 0
|
||||||
@defaultProps =
|
|
||||||
initialCount: 0
|
constructor: (props) ->
|
||||||
constructor: ->
|
super props
|
||||||
@state =
|
@state = count: props.initialCount
|
||||||
count: @props.initialCount
|
|
||||||
tick: =>
|
tick: =>
|
||||||
@setState count: @state.count + 1
|
@setState count: @state.count + 1
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
div(onClick: @tick, 'Clicks: ', @state.count)
|
div onClick: @tick,
|
||||||
|
'Clicks: '
|
||||||
|
@state.count
|
||||||
```
|
```
|
||||||
|
|
||||||
You can even use the old ES3 module pattern if you want:
|
You can even use the old ES3 module pattern if you want:
|
||||||
|
|||||||
Reference in New Issue
Block a user