Created
July 22, 2019 18:28
-
-
Save adrianolsk/20157371958a8b701882c750afbd9b87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
import { peopleReducer as peopleState } from './reducers/peopleReducer.ts'; | |
import { combineReducers } from 'redux'; | |
export const rootReducer = combineReducers({ | |
peopleState, | |
}); | |
export type AppState = ReturnType<typeof rootReducer>; | |
// 2 | |
type AppStateProps = ReturnType<typeof mapStateToProps>; | |
type AppDispatchProps = ReturnType<typeof mapDispatchToProps>; | |
type AppProps = AppStateProps & AppDispatchProps; | |
const App = (props: AppProps) => ( | |
<div> | |
{ /* ... */ } | |
</div> | |
) | |
const mapStateToProps = (state: AppState) => ({ | |
people: state.peopleState.people, | |
peopleLoading: state.peopleState.loading, | |
personPosting: state.peopleState.posting, | |
}); | |
const mapDispatchToProps = (dispatch: ThunkDispatch<any, any, AnyAction>) => { | |
return { | |
getPeople: () => dispatch(getPeopleActionCreator()), | |
postPerson: (person: IPostPerson) => dispatch(postPersonActionCreator(person)), | |
}; | |
}; | |
export default connect(mapStateToProps, mapDispatchToProps)(App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment