1.0.0-beta.3 • Published 4 years ago

@dxd/ashe v1.0.0-beta.3

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

CircleCI Version License

Ashe

Package with React component with hooks(as useState, useEffect, ...) wrapper for combining React with MobX. For documentation, see the MobX project. The package supports react with hooks only

Usage

  • npm i @dxd/ashe

  • store

import { observable, action } from 'mobx'

class Store {
  @observable a = 1

  @action.bound plus() {
    this.a += 1
  }
}

export default new Store()
  • Component

typescript

import * as React from 'react'
import { observer } from '../@dxd/ashe'
import x from './store'

const Example1: React.FunctionComponent = props => {
  const b = x.a + 1

  return (
    <>
      <p>hahaha{b}</p>
      <button onClick={x.plus}>++</button>
    </>
  )
}

Example1.displayName = 'Example1'

export default observer(Example1)

Examples

https://doxiaodong.github.io/ashe/index.html

Advance

  • You can find a DI in examples/store, which make stores testable