CoffeeScript-React

Counter.coffee

import {useState} from 'react'

export default Counter = ->
  [count, setCount] = useState 0

  <div>
    Count: {count}
    <button onClick={-> setCount count + 1}>
      Increment
    </button>
  </div>

Building with Parcel

  • Explicitly import React
import React from 'react'
import ReactDOM from 'react-dom'

ReactDOM.render <App />, document.getElementById 'app'