Skip to content

Commit

Permalink
fix(xplat): Fix FluentProvider, don't render style tag on native (#30837
Browse files Browse the repository at this point in the history
)

Add a isReactNative constant to explicitly check if on React Native. Update FluentProvider to not render a <style> tag on native.
  • Loading branch information
behowell committed Mar 20, 2024
1 parent 9f87d08 commit 75625f1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const getStylesFromClassName: (className: string) => {
[key: string]: unknown;
}[];

// @public (undocumented)
export const isReactNative: boolean;

// @public (undocumented)
export const jsxPlatformAdapter: (reactJsx: JSXRuntime) => JSXRuntime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { makeResetStyles } from './styling/makeResetStyles';
export { makeStyles } from './styling/makeStyles';
export { mergeClasses } from './styling/mergeClasses';
export { shorthands } from './styling/shorthands';
export { isReactNative } from './utilities/isReactNative';

// re-export some griffel types to have fluent use the griffel adapter instead of griffel directly
export { useRenderer_unstable, TextDirectionProvider } from '@griffel/react';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isReactNative: boolean = true;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isReactNative: boolean = false;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@fluentui/react-shared-contexts';
import type { FluentProviderContextValues, FluentProviderState, FluentProviderSlots } from './FluentProvider.types';
import { IconDirectionContextProvider } from '@fluentui/react-icons';
import { XPlatProvider } from '@fluentui/react-platform-adapter-preview';
import { isReactNative, XPlatProvider } from '@fluentui/react-platform-adapter-preview';

/**
* Render the final JSX of FluentProvider
Expand Down Expand Up @@ -41,7 +41,7 @@ export const renderFluentProvider_unstable = (
<IconDirectionContextProvider value={contextValues.iconDirection}>
<OverridesProvider value={contextValues.overrides_unstable}>
<state.root>
{canUseDOM() ? null : (
{canUseDOM() || isReactNative ? null : (
<style
// Using dangerous HTML because react can escape characters
// which can lead to invalid CSS.
Expand Down

0 comments on commit 75625f1

Please sign in to comment.