github Tencent/omi v6.10.0

latest releases: v7.6.6, v7.6.1, v7.5.6...
4 years ago

New functional styel API:

import { define, render } from 'omi'

class Store {
  data = {
    count: 1
  }
  sub = () => {
    this.data.count--
  }
  add = () => {
    this.data.count++
  }
}

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

render(<my-counter />, 'body', new Store)

The second parameter of define is optional.

Don't miss a new omi release

NewReleases is sending notifications on new releases.