Repository navigation
fix: add missing 'use client' directives - #812
Merged
Merged
Conversation
Add 'use client' directive to 10 source files that use React client hooks (createContext, useContext, useState, etc.) but were missing it. When tsup bundles these into shared chunks for the dist path, the missing directive causes Next.js builds to fail with 'createContext only works in a Client Component'. Files fixed: - PowerSearch/useInternalConfig.ts - PowerSearch/usePowerSearchConfig.ts - PowerSearch/usePowerSearchSource.ts - SideNav/XDSSideNavCollapseContext.ts - SideNav/XDSSideNavRenderContext.ts - SideNav/useResizable.ts - TopNav/TopNavContext.ts - TopNav/XDSTopNavMenu.tsx - TopNav/XDSTopNavMobileContentContext.ts - TopNav/XDSTopNavRenderContext.ts
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsPowerSearch · View in Storybook
SideNav · View in Storybook
TopNav · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 1 accessibility violation(s) found — 1 serious. XDSSideNav - 1 issue(s)
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
pushed a commit
that referenced
this pull request
Mar 22, 2026
Add 'use client' to all 95 source files using React client APIs. This ensures tsup shared chunks can preserve the directive (tsup only propagates it when ALL files in a chunk have it). Also adds scripts/check-use-client.mjs — a CI check that verifies all source files using client APIs have the directive. Files from original list (87): 85 needed the directive, 2 already had it from PR #812. Found 10 additional files that were also missing it (SegmentedControl, TreeList, SideNav, Selector/hooks, AppShell/MobileContext, hooks/useOverflow). Note: CI workflow integration deferred — requires workflow scope token. Run 'node scripts/check-use-client.mjs' after build.
cixzhang
added a commit
that referenced
this pull request
Mar 22, 2026
* fix: comprehensive 'use client' directives + source check Add 'use client' to all 95 source files using React client APIs. This ensures tsup shared chunks can preserve the directive (tsup only propagates it when ALL files in a chunk have it). Also adds scripts/check-use-client.mjs — a CI check that verifies all source files using client APIs have the directive. Files from original list (87): 85 needed the directive, 2 already had it from PR #812. Found 10 additional files that were also missing it (SegmentedControl, TreeList, SideNav, Selector/hooks, AppShell/MobileContext, hooks/useOverflow). Note: CI workflow integration deferred — requires workflow scope token. Run 'node scripts/check-use-client.mjs' after build. * fix: splitting: false + clean up duplicate use client directives * fix: restore XDSAppShell.tsx (accidentally emptied during cleanup) --------- Co-authored-by: Navi <[email protected]>
cixzhang
added a commit
that referenced
this pull request
Apr 26, 2026
cixzhang
added a commit
that referenced
this pull request
Apr 26, 2026
* fix: comprehensive 'use client' directives + source check Add 'use client' to all 95 source files using React client APIs. This ensures tsup shared chunks can preserve the directive (tsup only propagates it when ALL files in a chunk have it). Also adds scripts/check-use-client.mjs — a CI check that verifies all source files using client APIs have the directive. Files from original list (87): 85 needed the directive, 2 already had it from PR #812. Found 10 additional files that were also missing it (SegmentedControl, TreeList, SideNav, Selector/hooks, AppShell/MobileContext, hooks/useOverflow). Note: CI workflow integration deferred — requires workflow scope token. Run 'node scripts/check-use-client.mjs' after build. * fix: splitting: false + clean up duplicate use client directives * fix: restore XDSAppShell.tsx (accidentally emptied during cleanup) --------- Co-authored-by: Navi <[email protected]>
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
* fix: comprehensive 'use client' directives + source check Add 'use client' to all 95 source files using React client APIs. This ensures tsup shared chunks can preserve the directive (tsup only propagates it when ALL files in a chunk have it). Also adds scripts/check-use-client.mjs — a CI check that verifies all source files using client APIs have the directive. Files from original list (87): 85 needed the directive, 2 already had it from PR #812. Found 10 additional files that were also missing it (SegmentedControl, TreeList, SideNav, Selector/hooks, AppShell/MobileContext, hooks/useOverflow). Note: CI workflow integration deferred — requires workflow scope token. Run 'node scripts/check-use-client.mjs' after build. * fix: splitting: false + clean up duplicate use client directives * fix: restore XDSAppShell.tsx (accidentally emptied during cleanup) --------- Co-authored-by: Navi <[email protected]>
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
cixzhang
added a commit
that referenced
this pull request
Jun 21, 2026
* fix: comprehensive 'use client' directives + source check Add 'use client' to all 95 source files using React client APIs. This ensures tsup shared chunks can preserve the directive (tsup only propagates it when ALL files in a chunk have it). Also adds scripts/check-use-client.mjs — a CI check that verifies all source files using client APIs have the directive. Files from original list (87): 85 needed the directive, 2 already had it from PR #812. Found 10 additional files that were also missing it (SegmentedControl, TreeList, SideNav, Selector/hooks, AppShell/MobileContext, hooks/useOverflow). Note: CI workflow integration deferred — requires workflow scope token. Run 'node scripts/check-use-client.mjs' after build. * fix: splitting: false + clean up duplicate use client directives * fix: restore XDSAppShell.tsx (accidentally emptied during cleanup) ---------
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
'use client'directive to 10 source files that use React client hooks but were missing it. When tsup bundles these into shared chunks for the dist path, the missing directive causes Next.js builds to fail withcreateContext only works in a Client Component.Found by scanning all
packages/core/src/files for React client API imports without a corresponding'use client'directive.Files fixed
PowerSearch/useInternalConfig.ts—useMemoPowerSearch/usePowerSearchConfig.ts—useMemoPowerSearch/usePowerSearchSource.ts—useMemoSideNav/XDSSideNavCollapseContext.ts—createContext,useContextSideNav/XDSSideNavRenderContext.ts—createContext,useContextSideNav/useResizable.ts—useState,useEffect,useRef,useCallbackTopNav/TopNavContext.ts—createContext,useContextTopNav/XDSTopNavMenu.tsx—useState,useEffect,useRef,useCallback,useIdTopNav/XDSTopNavMobileContentContext.ts—createContext,useContextTopNav/XDSTopNavRenderContext.ts—createContext,useContextFixes the sandbox build failure in #806.