Skip to main content

React Context

This section will look at 10 progressive "levels" to do React context. Some of these levels are a bit muddled and may not sufficiently build off of the previous levels so don't look at them as perfectly progressive or that Level 8 is always better than Level 6. Here is a summary of what you'll find.

  • Level 1: Basic Context: this is a basic example of context where we create the context, a provider, and a hook to use the value of the context.
  • Level 2: Guarded Context: this is probably the best level to start at. Level 1 is fine while Level 2 adds a guard against calling outside of a provider.