https://github.com/j-xzy/type-redux-hook
type-redux的react hook
https://github.com/j-xzy/type-redux-hook
Last synced: 9 months ago
JSON representation
type-redux的react hook
- Host: GitHub
- URL: https://github.com/j-xzy/type-redux-hook
- Owner: j-xzy
- Created: 2019-03-01T08:26:44.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T09:20:47.000Z (almost 3 years ago)
- Last Synced: 2025-01-25T11:08:17.625Z (11 months ago)
- Language: TypeScript
- Size: 507 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# type-redux的react-hook
[](https://badge.fury.io/js/type-redux-hook)
[](https://www.travis-ci.org/whj1995/type-redux-hook)
[](https://coveralls.io/github/whj1995/type-redux-hook?branch=master)
```
npm install type-redux type-redux-hook
```
## 使用
``` ts
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;
```
``` ts
import { commit, dispatch, useMappedState } from './xxx';
function Component() {
const { list, maxId } = useMappedState((state) => ({ list: state.list, maxId: state.maxId }));
return
dispatch('xxx', 'xxx')} >;
}
```
## Example
https://github.com/whj1995/type-redux-hook/tree/master/demo