microsoft/vscode-documentdb/react-webview-architecture
Claude Code and agent skill by microsoft/vscode-documentdb
- community
- verified
Checking that the SKILL.md file is still in the repository.
Architecture patterns for React-based webviews in the vscode-documentdb extension. Use when creating new webview components, modifying existing views (CollectionView, DocumentView), working with state management (Context API), integrating Fluent UI components, handling Monaco Editor or SlickGrid, solving stale closure bugs with refs, or debugging webview rendering issues. Does NOT cover tRPC messaging (see webview-trpc-messaging skill) or accessibility/ARIA (see accessibility-aria-expert skill).
Install
npx vskill@latest install microsoft/vscode-documentdb/react-webview-architectureSKILL.md
React Webview Architecture
Patterns and conventions for React webviews in vscode-documentdb.
Related skills (do not duplicate):
- webview-trpc-messaging — tRPC routers, procedures, telemetry, AbortSignal, subscriptions, WebviewController
- accessibility-aria-expert — ARIA labels, Announcer, focus management, screen reader patterns
Full reference: See references/REACT_ARCHITECTURE_GUIDELINES.md
When to Use
- Creating or modifying a webview (DocumentView, CollectionView)
- Adding new components inside
src/webviews/ - Working with CollectionView context or state management
- Integrating Monaco Editor or SlickGrid
- Debugging stale closure issues in event handlers
Rendering Pipeline
Every webview boots through src/webviews/index.tsx:
- `VSCodeFluentProvider` — adapts Fluent UI theming to VS Code's active color theme. Lives in
@microsoft/vscode-ext-webview-fluentui, not insrc/; importing it also injects that package's Fluent overrides. - `WithWebviewContext` — provides
vscodeApi(postMessage) via React Context - `WebviewRegistry` — maps webview names → React components (in
_integration/WebviewRegistry)
Configuration from the extension host is read via useConfiguration<T>().
File Organization
Component Hierarchy
DocumentView (simpler, good reference pattern):
CollectionView (complex, multi-tab):
State Management
Simple views (DocumentView): local useState + props
Complex views (CollectionView): React Context with [state, setState] tuple
Always use functional updates when state depends on previous value:
Stale Closure Pattern (CRITICAL)
Third-party components (SlickGrid) bind event handlers at initialization — they don't update when state changes. Always use refs to access current data in those handlers:
Why: SlickGrid binds handlers once at init time. Without refs, handlers see the data from initialization, not the latest state. This caused multiple hard-to-debug issues.
Monaco Editor
Required patterns:
- Manual layout — Monaco doesn't auto-resize:
- Dispose on unmount:
- MonacoAutoHeight — self-sizing editor for query fields:
- JSON Schema delay — Monaco's JSON worker may not be ready immediately after mount. An AbortController-guarded delay is used (see QueryEditor for the pattern).
Fluent UI Integration
Use @fluentui/react-components (v9), themed via VSCodeFluentProvider:
| Component | Usage | |
|---|---|---|
ProgressBar | Loading states | |
Button, ToggleButton | Toolbar actions | |
Tab, TabList | View switching | |
Dropdown, Option | Selection (ViewSwitcher) | |
Badge | Status/preview indicators | |
MessageBar | Info/warning messages | |
Skeleton, SkeletonItem | Loading placeholders |
Animations: Collapse from @fluentui/react-motion-components-preview
Styling
- Each component gets its own
.scssfile, imported directly - Shared styles in
sharedStyles.scss, applied via@extend - Consistent spacing unit: `10px` with flexbox
row-gap/column-gap - No inline styles — move to SCSS files
- Avoid negative margins — fix layout with proper flexbox
Custom Hooks
| Hook | Purpose | |
|---|---|---|
useSelectiveContextMenuPrevention() | Prevents browser context menu everywhere except Monaco editors. Call once in top-level view. | |
useHideScrollbarsDuringResize() | Returns a function that temporarily hides scrollbars during layout transitions (500ms). |
Conditional Rendering Patterns
Object-based switch:
Loading State
Common Pitfalls
- Forgetting refs with third-party components → stale data in event handlers
- Not cleaning up event listeners, Monaco instances, AbortControllers in
useEffectreturn - Not calling `editor.layout()` after resize → blank Monaco panels
- Using `any` → use proper types or
unknownwith type guards - Missing `l10n.t()` on user-facing strings
- Inline styles instead of SCSS files
- Negative margins to fix spacing — restructure layout with flexbox gap instead
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 10 Mar 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/react-webview-architecture/SKILL.md
Popularity
- Repository stars
- 21
- Repository forks
- 8
- 7-day trend score
- 15
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 16 Mar 2026, 8 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/microsoft/vscode-documentdb/react-webview-architecture)