mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-07-13 15:28:32 +08:00
Added exercises
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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 = () => {
|
||||
// TODO: make use of useMappedState(state => state) and the useDispatch functions to get
|
||||
// the Redux store and dispatching actions
|
||||
// HINT: const { todos } = useMappedState(...);
|
||||
// HINT: useDispatch() here too.
|
||||
const todos = {};
|
||||
const dispatch = (...args: any[]) => {};
|
||||
|
||||
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>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user