1. 用到的组件订阅 reduce ,然后当做 prop
  2. 合适的地方更新 reduce 使用 dispatch 更新
  3. 定义声明 redux

Untitled

use.ts
export class ImageTextShortVideo extends React.Component<ImageTextShortVideoReducerState, ImageTextShortVideoState> {
	render (): JSX.Element {
        const { curTab } = this.props;
   }
}

export const ImageTextShortVideoStore = connect((store: StoreStates) => {
    return store.imageTextShortVideo;
})(ImageTextShortVideo);
state.ts
export const imageTextShortVideoStore = createReducer('imageTextShortVideo', initState);

action.ts
export const changeTab = (activeKey: string): void => {
    imageTextShortVideoStore.dispatch({ curTab: activeKey });
};

reducer.ts
import { UserInfo } from '../utils/userinfo';
import { AihelperReducerState } from 'pages/aihelper/store';
import { ImageTextShortVideoReducerState } from 'pages/imageTextShortVideo/state';

export interface StoreStates{
    userInfo: UserInfo;
    aihelper: AihelperReducerState;
    imageTextShortVideo: ImageTextShortVideoReducerState;
}

export interface ReducerAction<State> {
    type: string;
    data: State;
}