@cerebral/preact

Preact view for Cerebral.

Install

npm install @cerebral/preact preact babel-preset-preact

Container

import {h, render} from 'preact'
import {Controller} from 'cerebral'
import {Container} from '@cerebral/preact'
import App from './App'

const controller = Controller({
  state: {
    foo: 'bar'
  },
  signals: {
    clicked: []
  }
})

render((
  <Container controller={controller}>
    <App />
  </Container>
), document.querySelector('#app'))

connect

import {h, Component} from 'preact'
import {connect} from '@cerebral/preact'
import {state, signal} from 'cerebral/tags'

export default connect({
  foo: state`foo`,
  click: signal`clicked`
},
  class MyComponent extends Component {
    render ({foo, click}) {
      return <div onClick={() => click()}>{foo}</div>
    }
  }
)