( props: PackageLocalizationProviderProps )
| 28 | * needed by the client into the initial HTML. |
| 29 | */ |
| 30 | export 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. |
nothing calls this directly
no test coverage detected