rc-flex-store
A flexible state store for React component.
API
create(initialState: React.ComponentState, updaters?: { [updater: string]: any }, name?: string): Store;
- Create a store.
mount(store: Store, mapStoreToProps?: (store: UserStore, state: StoreState, props: Props) => Props, forwardRef?: boolean): React.Component
- Mount a store provider to react component.
connect(store: Store, mapStoreToProps?: (store: UserStore, state: StoreState, props: Props) => Props;, forwardRef?: boolean): React.Component
- Connect react component to a store consumer.
Usage
import ReactDOM from 'react-dom';import React Fragment from 'react';import create mount connect from 'rc-flex-store'; const counter = ; @PureComponent { const count = thisprops; return <div> count </div>; } @PureComponent { const decrement increment = thisprops; return <div> <button =>-</button> <button =>+</button> </div> ; } @Component { return <Fragment> <CounterView /> <CounterAction /> </Fragment> ; } ReactDOM;
Example
Support
Support
React >= 16.3.0
, if useReact < 16.3.0
please addReact.createContext
polyfill. See create-react-context.