2.0.0 • Published 4 years ago
type-redux-hook v2.0.0
type-redux的react-hook
npm install type-redux type-redux-hook
使用
import { createUseMappedState } from 'type-redux-hook';
import { createStore } from 'type-redux';
...
const store = createStore(todo, state);
export const useMappedState = createUseMappedState(store);
export const commit = store.commit;
export const dispatch = store.dispatch;
import { commit, dispatch, useMappedState } from './xxx';
function Component() {
const { list, maxId } = useMappedState((state) => ({ list: state.list, maxId: state.maxId }));
return <div onClick={() => dispatch('xxx', 'xxx')} ></div>;
}