preact · Preact Docs
Preact Context
Explains how to implement the Context API in Preact to manage global state and avoid prop drilling by using the createContext function, Providers, and Consumers.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Preact Context
Explains how to implement the Context API in Preact to manage global state and avoid prop drilling by using the createContext function, Providers, and Consumers.
When To Use
Use when you need to pass data through multiple layers of a component tree without manually passing props through every intermediate component.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/preact-context-workflow-guide.md | A comprehensive guide covering the essentials, debugging, testing, and advanced usage of the Preact Context API. | Questions about a comprehensive guide covering the essentials, debugging, testing, and advanced usage of the Preact Context API. |
examples/preact-context-api-usage.text | A text-based demonstration of creating and using multiple context providers and consumers in Preact. | Exact payloads, commands, or snippets shown in A text-based demonstration of creating and using multiple context providers and consumers in Preact. |
examples/preact-context-createcontext.text | A code example demonstrating how to use the createContext function in Preact to manage shared state. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the createContext function in Preact to manage shared state. |
examples/preact-context-createcontext-component.text | A code example demonstrating how to use createContext and static contextType within a Preact component to manage theme state. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use createContext and static contextType within a Preact component to manage them... |
examples/preact-context-createcontext-usecontext.text | A code example demonstrating how to use createContext and useContext to manage theme state in a Preact application. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use createContext and useContext to manage theme state in a Preact application. |
examples/preact-context-createcontext-usage.text | A code example demonstrating how to use the createContext function to pass data through the component tree in Preact. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the createContext function to pass data through the component tree in Preact. |
examples/preact-context-usecontext-theme.text | A code example demonstrating how to implement a theme switcher using the Preact Context API and the useContext hook. | Exact payloads, commands, or snippets shown in A code example demonstrating how to implement a theme switcher using the Preact Context API and the useContext hook. |
examples/preact-context-component-class.text | A code example demonstrating how to use the getChildContext method within a class component to provide context in Preact. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the getChildContext method within a class component to provide context in Pre... |
What This Skill Covers
- Guide Version: 11.x (preview) 10.x (current) 8.x
- Main sections:
Introduction,Essentials,Debug & Test,Advanced,Libraries.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://preactjs.com/guide/v10/context