brain-store-react
v1.1.1
Published
brain store react package
Downloads
16
Maintainers
Readme
brain-store-react
基于 store 处理的一些函数,组件等。如绑定状态,扩展 mobx-react Provider 组件。
use
API
bind
import Store,{ StoreModules } from 'brain-store'; @StoreModules('ContainerStore') export default class ContainerStore extends StoreBase{ static meta={ ..StoreBase.meta, eventScopes:[], contextTypes:{ } } constructor(context){ super(context); } @observable count; @action setCount(){ this.count++; } }
import { bind } from 'brain-store-react'; import React from 'react'; @bind({ store: ContainerStore }) export default class ReactTest extends React.Component { constructor(props) { super(props); this.props.store; } }
Provider
import { Provider } from 'brain-store-react'; import React from 'react'; export default class ProviderTest extends React.Component { render() { const { store, children } = this.props; return <Provider store={store}>{children}</Provider>; } }
import {observer} from 'brain-store-react';
Licensing
MIT license