import React from 'react'; import { Store } from '../store'; import { DefaultButton, Text, Stack } from 'office-ui-fabric-react'; import { connect } from 'react-redux'; import { actionsWithService } from '../actions'; interface TodoFooterProps { clear: () => void; todos: Store['todos']; } const TodoFooter = (props: TodoFooterProps) => { const itemCount = Object.keys(props.todos).filter(id => !props.todos[id].completed).length; return ( {itemCount} item{itemCount === 1 ? '' : 's'} left props.clear()}>Clear Completed ); }; function mapStateToProps(state: Store) { return { ...state }; } function mapDispatchToProps(dispatch: any) { return { clear: () => dispatch(actionsWithService.clear()) }; } const component = connect( mapStateToProps, mapDispatchToProps )(TodoFooter); export { component as TodoFooter };