1.0.4 • Published 4 years ago

mobx-hook v1.0.4

Weekly downloads
6
License
MIT
Repository
-
Last release
4 years ago

mobx-hook

mobx-hook is a refactor version of mobx, design for react hook.

install

use npm

npm i mobx-hook

or use yarn

yarn add mobx-hook

how to use ?

import React from 'react'
import { useData } from 'mobx-hook'

function Counter() {
  const state = useData({ x: 0 })
  return (
    <button onClick={() => ++state.x}>
      you click {state.x} times.
    </button>
  )
}

how to write the global store

import React from 'react'
import { createStoreHook } from 'mobx-hook'

const useStore = createStoreHook({
  click: 0,
  add() { this.click ++ }
})

function Counter() {
  const store = useStore()
  return (
    <button onClick={store.add}>
      you click {store.click} times total.
    </button>
  )
}
1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.1

5 years ago