mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
29 lines
821 B
TypeScript
29 lines
821 B
TypeScript
import * as actions from '../actions';
|
|
import { Store, FilterTypes } from '../store';
|
|
import { connect } from 'react-redux';
|
|
import { Dispatch } from 'redux';
|
|
import { TodoApp } from './TodoApp';
|
|
|
|
export function mapStateToProps({ todos, filter }: Store) {
|
|
return {
|
|
todos,
|
|
filter
|
|
};
|
|
}
|
|
|
|
export function mapDispatchToProps(dispatch: Dispatch<actions.TodoAction>) {
|
|
return {
|
|
add: (label: string) => dispatch(actions.add(label)),
|
|
remove: (id: string) => dispatch(actions.remove(id)),
|
|
complete: (id: string) => dispatch(actions.complete(id)),
|
|
completeAll: () => dispatch(actions.completeAll()),
|
|
clear: () => dispatch(actions.clear()),
|
|
setFilter: (filter: FilterTypes) => dispatch(actions.filter(filter))
|
|
};
|
|
}
|
|
|
|
export default connect(
|
|
mapStateToProps,
|
|
mapDispatchToProps
|
|
)(TodoApp);
|