coffee-react-browser

1.0.1 • Public • Published

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>

Readme

Keywords

none

Package Sidebar

Install

npm i coffee-react-browser

Weekly Downloads

2

Version

1.0.1

License

ISC

Last publish

Collaborators

  • jsdf