You may come upon a case where you have a generic component that can consume a Context, but doesn’t require that Context in order to work. On the flip side, you may want to validate that a component is always used inside a required parent Context. In this lesson we’ll see how to set a default value on a Provider and access that default in the Consumer, as well as how to validate that a Consumer is used correctly, by checking the value it receives and throwing an error if it is missing.
The code here, like in the first lesson, is the completed version rather than the start code.
The 'before' code for this lesson can be found here.