jongacnik / monoapp-react

monoapp plugin to use React as a view layer
11 stars 2 forks source link

monoapp-react

monoapp plugin to use React as a view layer

Example

var monoapp = require('monoapp')
var withReact = require('monoapp-react')

var app = monoapp()

app.use(withReact)
app.route('/', view)
app.mount('#app')

function MyComponent () {
  return <div>Hello World</div>
}

function view (state, emit) {
  return (
    <main>
      <MyComponent />
    </main>
  ) 
}

Component

An instance of React.Component extended with monoapp state and emit is included:

var { Component } = require('monoapp-react')

class MyComponent extends Component {
  render () {
    console.log(this.global)
    console.log(this.emit)

    return <div>Hello World</div>
  }
}