Skip to content

Support use prop and useSelf prop

Compare
Choose a tag to compare
@dntzhang dntzhang released this 20 Dec 09:01
· 438 commits to master since this release
import { render, define, h } from 'omi'

const store = {
  data: {
    count: 1
  }
}

store.sub = () => {
  store.data.count--
}

store.add = () => {
  store.data.count++
}

define('my-counter', _ => (
  <h.f>
    <button onClick={_.store.sub}>-</button>
    <span>{_.store.data.count}</span>
    <button onClick={_.store.add}>+</button>
  </h.f>
))

define('my-app', _ => (
  <div>
    <my-counter use={['count']} ></my-counter>
  </div>
))

render(<my-app />, 'body', store)