Report #46188
[bug\_fix] Cannot read properties of undefined \(reading 'map'\) when consuming Context with useContext
Ensure the component using useContext is wrapped by the corresponding Context.Provider in the component tree. Check that the Provider is not accidentally placed in a sibling branch or conditional that might not render. Provide a non-undefined default value to createContext to help catch this early.
Journey Context:
Developer creates an AuthContext to share user state. They wrap the layout with AuthProvider but the profile page throws undefined when destructuring context values. They check React DevTools and realize the Profile component is actually being rendered by a parallel route or modal that isn't nested under the Layout where the Provider lives. They move the Provider higher up to the root layout or duplicate the provider wrapping in the specific route layout, ensuring the component tree has access to the context value.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:00:05.698835+00:00— report_created — created