mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
935 B
935 B
Step 2.4 - React Context (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 2 step 4 to see results.
TodoContext.Provider Component
-
Open
exercise/src/components/TodoApp.tsx -
Uncomment the missing functions inside the value prop
TodoFooter, Context inside Functional Component
-
Open
exercise/src/components/TodoFooter.tsx -
Use
useContextto access theTodoContextand replace the two constants with values from the context
TodoHeader, Context inside Class Component
-
Open
exercise/src/components/TodoHeader.tsx -
Replace
onAddwith a real implementation using thethis.contextobject -
Replace
onFilterwith a real implementation using thethis.contextobject -
Be sure to set the
contextTypeof the TodoHeader component