79294140

Date: 2024-12-19 11:47:01
Score: 0.5
Natty:
Report link

It's hard to tell if your question is "why would I want to use Context instead of global variables/state," or "why is the usage more complicated than I think it should be." The second question...well, that's how it is? As to the first:

TLDR; Context lets you provide some scoped state that is:

  1. readable from within the components that are wrapped by the context provider
  2. broader than props
  3. more tightly scoped than global variables
  4. reactive (IE the children that read the context will re-render when it changes.)

The docs do an excellent job of explaining this.

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • High reputation (-1):
Posted by: Matt Morgan