de109cc299 | ||
---|---|---|
.. | ||
src | ||
README.md | ||
index.html |
README.md
Exercise
If you don't already have the app running, start it by running npm start
from the root of the frontend-bootcamp
folder. Click the "exercise" link under day 1 step 7 to see results.
TodoFooter
-
Open TodoFooter and write a TodoFooterProps interface. It should include two values, a function and an object. Use this interface in the function props like this:
(props: TodoFooterProps)
-
Write an
_onClick
function that callsprops.clear
.Since TodoFooter is not a class, the
_onClick
function needs to be stored in a const placed before thereturn
. -
Assign
_onClick
to the button'sonClick
prop. You won't need to usethis
since the component isn't a class. -
Test out this functionality. Check a few todos complete and click the
Clear Completed
button.
TodoHeader
-
Open TodoHeader and write TodoHeaderProps which will include three values. Replace the first
any
in the class declaration with this interface. -
This component also has state. Write TodoHeaderState (there's just one value), and add this where the second
any
was. -
Add
_onFilter
to each of the filter buttonsNote that we can't add new parameters to onClick, but we can pull information from the event target!
-
Write an
_onAdd
method that callsaddTodo
on the currentlabelInput
, then sets thelabelInput
in state to an empty string -
Call
_onAdd
from the submit button -
Check out this new functionality! We can now add and filter todos!