#Step 1-07: Exercise
TodoFooter
-
Open TodoFooter and write a TodoFooterProps interface. It should include two values, a
clearandtodos. Use this interface in the function props like this:(props: TodoFooterProps) -
Write an
_onClickfunction that callsprops.clear.Since TodoFooter is not a class, the
_onClickfunction needs to be stored in a const placed before thereturn. -
Assign
_onClickto the button'sonClickprop. You won't need to usethissince the component isn't a class. -
Test out this functionality. Check a few todos complete and click the
Clear Completedbutton.
TodoHeader
-
Open TodoHeader and write TodoHeaderProps which will include
addTodo,setFilterandfilter. Replace the firstanyin the class declaration with this interface. -
This component also has state. Write TodoHeaderState (there's just one value), and add this where the second
anywas. -
Add
_onFilterto each of the filter buttonsNote that we can't add new parameters to onClick, but we can pull information from the event target!
-
Call
_onAddfrom the submit button -
Check out this new functionality! We can now add and filter todos!