MCPcopy Create free account
hub / github.com/adobe/react-spectrum / PackageLocalizationProvider

Function PackageLocalizationProvider

packages/react-aria/src/i18n/server.tsx:30–48  ·  view source on GitHub ↗
(
  props: PackageLocalizationProviderProps
)

Source from the content-addressed store, hash-verified

28 * needed by the client into the initial HTML.
29 */
30export function PackageLocalizationProvider(
31 props: PackageLocalizationProviderProps
32): JSX.Element | null {
33 if (typeof document !== 'undefined') {
34 console.log('PackageLocalizationProvider should only be rendered on the server.');
35 return null;
36 }
37
38 let {nonce, locale, strings} = props;
39 // suppressHydrationWarning is necessary because the browser
40 // remove the nonce parameter from the DOM before hydration
41 return (
42 <script
43 nonce={typeof window === 'undefined' ? nonce : ''}
44 suppressHydrationWarning
45 dangerouslySetInnerHTML={{__html: getPackageLocalizationScript(locale, strings)}}
46 />
47 );
48}
49
50/**
51 * Returns the content for an inline `<script>` tag to inject localized strings into initial HTML.

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected