DetailsContainer.ts 700 B

1234567891011121314151617181920212223242526
  1. import { connect } from 'react-redux';
  2. import {
  3. fetchTopicList,
  4. } from 'redux/reducers/topics/thunks';
  5. import Details from './Details';
  6. import { RootState } from 'types';
  7. import { getTopicByName } from 'redux/reducers/topics/selectors';
  8. import { withRouter, RouteComponentProps } from 'react-router-dom';
  9. interface RouteProps {
  10. topicName: string;
  11. }
  12. interface OwnProps extends RouteComponentProps<RouteProps> { }
  13. const mapStateToProps = (state: RootState, { match: { params: { topicName } } }: OwnProps) => ({
  14. topic: getTopicByName(state, topicName),
  15. });
  16. const mapDispatchToProps = {
  17. fetchTopicList,
  18. }
  19. export default withRouter(
  20. connect(mapStateToProps, mapDispatchToProps)(Details)
  21. );