github Tencent/omi v6.17.0
Support use prop and useSelf prop

latest releases: v7.6.6, v7.6.1, v7.5.6...
4 years ago
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)

Don't miss a new omi release

NewReleases is sending notifications on new releases.