diff --git a/example/rematch-tsx/src/models/index.tsx b/example/rematch-tsx/src/models/index.tsx index fbd2079c..b0ee806e 100644 --- a/example/rematch-tsx/src/models/index.tsx +++ b/example/rematch-tsx/src/models/index.tsx @@ -1,5 +1,5 @@ import { init, RematchRootState, RematchDispatch, Models } from '@rematch/core'; -import loadingPlugin, { ExtraModelsFromLoading } from "@rematch/loading"; +import loadingPlugin, { ExtraModelsFromLoading } from '@rematch/loading'; import global from './global'; import login from './login'; @@ -10,7 +10,7 @@ export interface RootModel extends Models, FullModel { type FullModel = ExtraModelsFromLoading; -export const models: RootModel = { global } as RootModel; +export const models = { global } as RootModel; export const store = init({ models, plugins: [loadingPlugin()], @@ -19,5 +19,7 @@ export const store = init({ export const { dispatch } = store; export type Store = typeof store; +// export type Dispatch = RootModel; +// export type Dispatch = ReduxDispatch; export type Dispatch = RematchDispatch; export type RootState = RematchRootState; diff --git a/example/rematch-tsx/src/pages/login/index.tsx b/example/rematch-tsx/src/pages/login/index.tsx index 3d7542da..3783ddeb 100644 --- a/example/rematch-tsx/src/pages/login/index.tsx +++ b/example/rematch-tsx/src/pages/login/index.tsx @@ -11,12 +11,13 @@ const mapState = ({ login, loading }: RootState) => ({ account: login.userData, }); -const mapDispatch = (dispatch: Dispatch) => ({ +const mapDispatch: any = (dispatch: Dispatch) => ({ submit: dispatch.login.submit, }); -type connectedProps = ReturnType & ReturnType; -type Props = connectedProps & DefaultProps; +type StateProps = ReturnType; +type DispatchProps = ReturnType; +type Props = StateProps & DispatchProps & DefaultProps; function Login(props: Props) { const { loading } = props; diff --git a/example/rematch-tsx/src/routes/Controller.tsx b/example/rematch-tsx/src/routes/Controller.tsx index b2e41535..7d44a742 100644 --- a/example/rematch-tsx/src/routes/Controller.tsx +++ b/example/rematch-tsx/src/routes/Controller.tsx @@ -2,11 +2,13 @@ import React from 'react'; import { Switch, Route } from 'react-router-dom'; import { connect } from 'react-redux'; import { Dispatch, RootState } from '../models'; +import { getRouterData } from '../routes/router'; -type connectedProps = ReturnType & ReturnType; -type Props = connectedProps & - typeof Controller.defaultProps & { - routerData: any; +type StateProps = ReturnType; +type DispatchProps = ReturnType; +type Props = StateProps & + DispatchProps & { + routerData: typeof getRouterData; }; const mapState = ({ global }: RootState) => ({ @@ -14,13 +16,12 @@ const mapState = ({ global }: RootState) => ({ // userData: global.userData, }); -const mapDispatch = (dispatch: Dispatch) => ({ +const mapDispatch: any = (dispatch: Dispatch) => ({ // verify: dispatch.global.verify, // verify: global.verify, }); class Controller extends React.PureComponent { - static defaultProps = {}; componentDidMount() { // this.props.verify(); }