diff --git a/step2-07/demo/src/components/TodoFooter.tsx b/step2-07/demo/src/components/TodoFooter.tsx index abd4932..d876d41 100644 --- a/step2-07/demo/src/components/TodoFooter.tsx +++ b/step2-07/demo/src/components/TodoFooter.tsx @@ -10,7 +10,8 @@ interface TodoFooterProps { } const TodoFooter = (props: TodoFooterProps) => { - const itemCount = Object.keys(props.todos).filter(id => !props.todos[id].completed).length; + const { todos } = props; + const itemCount = todos ? Object.keys(todos).filter(id => !props.todos[id].completed).length : 0; return ( diff --git a/step2-07/exercise/README.md b/step2-07/exercise/README.md index a080727..f276754 100644 --- a/step2-07/exercise/README.md +++ b/step2-07/exercise/README.md @@ -4,7 +4,7 @@ If you still have `npm test` running from the last step, stop it using `ctrl+C`. Start the app by running `npm start` from the root of the `frontend-bootcamp` folder. Click the "exercise" link under day 2 step 7 to see results. -1. open up `exercise/src/index.tsx` and wrap `` with `` as instructed in the comment +1. open up `exercise/src/index.tsx` and note the `` - see how it wraps the components as the new root component. 2. open up `exercise/src/components/TodoFooter.tsx` and erase the "nullable" type modifier (i.e. the ?) in the interface definition of `TodoFooterProps` diff --git a/step2-07/exercise/src/components/TodoFooter.tsx b/step2-07/exercise/src/components/TodoFooter.tsx index 6c11cbc..b97194a 100644 --- a/step2-07/exercise/src/components/TodoFooter.tsx +++ b/step2-07/exercise/src/components/TodoFooter.tsx @@ -11,7 +11,8 @@ interface TodoFooterProps { } export const TodoFooter = (props: TodoFooterProps) => { - const itemCount = Object.keys(props.todos).filter(id => !props.todos[id].completed).length; + const { todos } = props; + const itemCount = todos ? Object.keys(todos).filter(id => !props.todos[id].completed).length : 0; return ( diff --git a/step2-07/exercise/src/index.tsx b/step2-07/exercise/src/index.tsx index 6c891b4..f14f51c 100644 --- a/step2-07/exercise/src/index.tsx +++ b/step2-07/exercise/src/index.tsx @@ -15,5 +15,10 @@ store.dispatch(actions.addTodo('world')); initializeIcons(); -// TODO: wrap with a instance here -ReactDOM.render(, document.getElementById('app')); +// TODO: see how we added Provider is the root element +ReactDOM.render( + + + , + document.getElementById('app') +); diff --git a/step2-08/demo/src/components/TodoFooter.tsx b/step2-08/demo/src/components/TodoFooter.tsx index 417c3e2..5805f34 100644 --- a/step2-08/demo/src/components/TodoFooter.tsx +++ b/step2-08/demo/src/components/TodoFooter.tsx @@ -10,7 +10,8 @@ interface TodoFooterProps { } const TodoFooter = (props: TodoFooterProps) => { - const itemCount = Object.keys(props.todos).filter(id => !props.todos[id].completed).length; + const { todos } = props; + const itemCount = todos ? Object.keys(todos).filter(id => !props.todos[id].completed).length : 0; return (