coffee-react-browser
v1.0.1
Published
Run CJSX script tags in the browser
Downloads
1
Readme
coffee-react-browser
Run CJSX script tags in the browser
example
<!DOCTYPE html>
<html>
<head>
<title>CJSX in a script tag</title>
<script src="https://fb.me/react-0.13.2.js"></script>
<script type="text/javascript" src="https://wzrd.in/standalone/coffee-react-browser"></script>
<script type="text/cjsx">
# defining a component
class Clock extends React.Component
@defaultProps = interval: 2000
constructor: (props) ->
super props
@state = time: new Date
componentDidMount: ->
setInterval(@tick, @props.interval)
tick: =>
@setState time: new Date
render: ->
<h1>{@state.time.toLocaleTimeString()}</h1>
# rendering to the page
React.render(<Clock interval={100} />, document.body)
# that's all folks :D
</script>
</head>
<body>
</body>
</html>