🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

source-react-coffee

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

source-react-coffee

React in CoffeeScript without escaping into JSX or painfully contorting syntax.

latest
Source
npmnpm
Version
0.2.2
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

This is an attempt to make Facebook's react library more usable from CoffeeScript without escaping into JSX or painfully contorting syntax. Here's what I have so far.

{React, Component, renderComponent} = require 'react-coffee'

class TodoList extends Component
  render: ->
    @ul ->
      @li text for text in this.props.items

class TodoApp extends Component
  getInitialState: ->
    items: []
    text: ''

  onChange: (e) =>
    @setState(text: e.target.value)

  handleSubmit: (e) =>
    e.preventDefault()

    nextItems = @state.items.concat([@state.text])
    nextText = ''
    @setState(items: nextItems, text: nextText)

    @refs.nameInput.getDOMNode().focus()

  render: ->
    @div ->
      @h3 'TODO'
      @component TodoList, items: @state.items
      @form onSubmit: @handleSubmit, ->
        @input onChange: @onChange, ref: 'nameInput', value: @state.text
        @button "Add ##{@state.items.length + 1}"

component = new TodoApp()
renderComponent(component, document.getElementById('app'))

FAQs

Package last updated on 30 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts