monoapp plugin to use React as a view layer
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>
)
}
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>
}
}