[]previous and next page

Common mistakes

Common mistakes in the Context guide.

For agentsUpdated
  • value={signal()}. The provider reads the value once. Provide the accessor (value={signal}) or a store.
  • Calling useContext in a handler, a timer or after await. There is no owner. Read it during setup and close over it, or capture the owner and use runWithOwner.
  • createContext<string | undefined>(undefined) as an optional context. An undefined default throws like no default. Use null.
  • Importing a context from two copies of the package. Contexts are matched by a symbol created in createContext. Two bundled copies of a module that defines a context have two symbols.