step 2.6 demo refinement

This commit is contained in:
Ken
2019-03-02 22:24:18 -08:00
parent 1f4baa2ca4
commit 562d3bc20d
15 changed files with 268 additions and 178 deletions

View File

@@ -0,0 +1,20 @@
import React from 'react';
import { DefaultButton, Stack, Text } from 'office-ui-fabric-react';
import { actions } from '../actions';
import { useMappedState, useDispatch } from 'redux-react-hook';
export const TodoFooter = () => {
const { todos } = useMappedState(state => state);
const dispatch = useDispatch();
const itemCount = Object.keys(todos).filter(id => !todos[id].completed).length;
return (
<Stack horizontal horizontalAlign="space-between">
<Text>
{itemCount} item{itemCount === 1 ? '' : 's'} left
</Text>
<DefaultButton onClick={() => dispatch(actions.clear())}>Clear Completed</DefaultButton>
</Stack>
);
};