============================================================================
Date: May 6th, 2019
[x] Create a Counter Provider component, which exposes the following state:
-
count
- A number (default to 0) - [x]
increment
- A reference to a function that increases the count -
decrement
- A reference to a function that decreases the count - In the index.js, import CounterContext and wrap
<App />
in it, so that all child components can optionally subscribe to it as consumers. - Your
<App />
component should simply pull in and render the following child components ... - Create the following child components that register as a
.Consumer
to the provided context.-
<Incrementer />
- Renders a button that, when clicked, calls theincrement()
method in theCounter Provider
-
<Decrementer />
- Renders a button that, when clicked, calls thedecrement()
method in theCounter Provider
-
<Counter />
- Renders the current value ofcount
from the Counter Provider
-
- Provide good styling. Use the css-in-js methodology within the components themselves.
You have been provided, in the starter-code
folder, a working To Do manager application, written using standard React Component State
- Refactor the app to make use of Context
- Create a
context
for the Application - Create a separate
<Counter />
component that reads and displays thecount
from Context - Create separate components for the main To App elements
-
form
- Adds and updates to do list items -
list
- Lists items, manages complete state and form visibility
-
[ ] Do a deep mount of the app, and set tests to make assertions on the child components that consume context from the Provider.
[ ] Can they see context? [ ] Can they interact via published functions?