Skip to content

fix: add missing "use client" directive to client components and styles#35719

Merged
Hotell merged 11 commits intomicrosoft:masterfrom
dmytrokirpa:fix/missing-use-client
Feb 12, 2026
Merged

fix: add missing "use client" directive to client components and styles#35719
Hotell merged 11 commits intomicrosoft:masterfrom
dmytrokirpa:fix/missing-use-client

Conversation

@dmytrokirpa
Copy link
Contributor

@dmytrokirpa dmytrokirpa commented Feb 3, 2026

Previous Behavior

Multiple Fluent UI v9 packages were missing the 'use client' directive in their compiled JavaScript output, causing React Server Components (RSC) compatibility issues. Components that use client-side APIs (hooks, DOM manipulation, browser APIs) were being treated as server components by default, leading to runtime errors when developers tried to use them in RSC environments.

Affected packages included:

  • @fluentui/react-text - Text preset components and style hooks
  • @fluentui/react-utilities - Client-side hooks like useIsomorphicLayoutEffect
  • @fluentui/react-shared-contexts - Context files requiring client-side rendering
  • @fluentui/react-message-bar
  • @fluentui/react-motion-components-preview
  • Various utility files using getWindow() and other browser APIs

New Behavior

All client-side components, hooks, and utilities now include the 'use client' directive in their source files. This ensures that:

  • Components are properly marked for client-side rendering in RSC environments
  • Developers can import and use Fluent UI v9 components directly in Next.js App Router and other RSC frameworks
  • The build output correctly propagates the directive to consumers

Files updated include:

  • Component style files and hooks that access browser APIs
  • React migration library components (v0-v9 and v8-v9)
  • Utility files like getWindow that require client-side execution
  • Context providers and custom hooks

Related Issue(s)

- Added "use client" directive to global-context-selector.ts, useDisableBodyScroll.styles.ts, and multiple Attachment component styles.
- Updated various components in react-migration-v0-v9 and react-migration-v8-v9 libraries to include "use client" for compatibility with client-side rendering.
- Included "use client" in utility hooks and context files to ensure proper execution in client environments.
- Adjusted imports and ensured consistent application of the directive across all affected files.
@dmytrokirpa dmytrokirpa self-assigned this Feb 3, 2026
@dmytrokirpa dmytrokirpa added Area: SSR Server-side rendering React 19 labels Feb 3, 2026
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

📊 Bundle size report

✅ No changes found

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Pull request demo site: URL

@dmytrokirpa dmytrokirpa marked this pull request as ready for review February 4, 2026 11:06
@tudorpopams tudorpopams requested a review from Hotell February 4, 2026 13:09
Copy link
Contributor

@Hotell Hotell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments where some need action, overall LGTM, ty

/**
* Track imported custom hooks and RSC-unsface functions
*/
ImportDeclaration(node: TSESTree.ImportDeclaration) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we merge this with Identifier visitor logic ? as we are already checking if its coming from import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hotell Hotell merged commit 16db0e6 into microsoft:master Feb 12, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Missing 'use client' directive in compiled output breaks RSC

5 participants