1.1.1 • Published 3 years ago

reapex-react v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

reapex-react

Reapex binding for React

How to use:

import { useModel } from 'reapex-react'
import { App } from 'reapex'
import { render } from 'react-dom'

export const app = new App()

const CounterModel = app.model('Counter', { total: 50 })

const [mutations] = CounterModel.mutations({
  increase: () => ({ total }) => ({ total: total + 1 }),
  decrease: () => ({ total }) => ({ total: total - 1 }),
})

const CounterComponent = () => {
  const total = useModel(CounterModel, (counter) => counter.total)

  return (
    <div>
      <button onClick={mutations.decrease}>-</button>
      {total}
      <button onClick={mutations.increase}>+</button>
    </div>
  )
}

render(<CounterComponent />, document.getElementById('root'))
1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

1.0.0-beta.28

3 years ago

1.0.0-beta.27

3 years ago

1.0.0-beta.26

4 years ago

1.0.0-beta.24

4 years ago

1.0.0-beta.23

4 years ago

1.0.0-beta.22

4 years ago