1.1.1 • Published 2 years ago

reapex-react v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 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

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

1.0.0-beta.28

2 years ago

1.0.0-beta.27

2 years ago

1.0.0-beta.26

3 years ago

1.0.0-beta.24

3 years ago

1.0.0-beta.23

3 years ago

1.0.0-beta.22

3 years ago