Skip to content

Commit

Permalink
chore: add thunk return typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dpyzo0o committed Dec 30, 2019
1 parent dd6d80d commit fb5189f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/pages/demo/demo.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Taro from '@tarojs/taro';
import { View, Button } from '@tarojs/components';
import { useSelector, useDispatch } from '@tarojs/redux';
import { AppDispatch } from '~/redux/store';
import { RootState } from '~/redux/rootReducer';
import { increment } from '~/redux/slices/count';
import useUnload from '~/hooks/useUnload';
import useBoolean from '~/hooks/useBoolean';

const Demo: Taro.FC = () => {
const dispatch = useDispatch();
const dispatch = useDispatch<AppDispatch>();
const count = useSelector((state: RootState) => state.count);
const { state, toggle, setTrue, setFalse } = useBoolean(false);

Expand Down
3 changes: 2 additions & 1 deletion src/pages/index/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useSelector, useDispatch } from '@tarojs/redux';
import { View, Button, Input, Image } from '@tarojs/components';
import { CommonEventFunction } from '@tarojs/components/types/common';

import { AppDispatch } from '~/redux/store';
import useUnload from '~/hooks/useUnload';
import { RootState } from '~/redux/rootReducer';
import { increment, decrement, asyncIncrement, asyncDecrement } from '~/redux/slices/count';
Expand All @@ -12,7 +13,7 @@ import warningIcon from '~/assets/warning.png';
import './index.scss';

const Index: Taro.FC = () => {
const dispatch = useDispatch();
const dispatch = useDispatch<AppDispatch>();

const [input, setInput] = useState('');

Expand Down
2 changes: 1 addition & 1 deletion src/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ const store = configureStore({

export type AppDispatch = typeof store.dispatch;

export type AppThunk = ThunkAction<void, RootState, null, Action<string>>;
export type AppThunk<T = void> = ThunkAction<Promise<T>, RootState, null, Action<string>>;

export default store;

0 comments on commit fb5189f

Please sign in to comment.