j-xzy / type-redux-hook

type-redux的react hook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

type-redux的react-hook

npm version Build Status Coverage Status

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>;
}

Example

https://github.com/whj1995/type-redux-hook/tree/master/demo

About

type-redux的react hook


Languages

Language:TypeScript 88.0%Language:JavaScript 9.1%Language:HTML 2.9%