mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Fix an error where a Theme nonce value could cause inconsistencies between server- and client-side rendering. (#237)
This commit is contained in:
@@ -14,7 +14,16 @@ export function ClientContexts(props: {
|
||||
forcedTheme: CustomizationThemeMode | undefined;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const { nonce, children, forcedTheme, language } = props;
|
||||
const { children, forcedTheme, language } = props;
|
||||
|
||||
/**
|
||||
* A bug in ThemeProvider is causing the nonce to be included incorrectly
|
||||
* on the client-side. Original issue: https://github.com/pacocoursey/next-themes/issues/218
|
||||
*
|
||||
* This is a workaround for it, until next-themes fixes it in their library. There is already
|
||||
* a PR: https://github.com/pacocoursey/next-themes/pull/223
|
||||
*/
|
||||
const nonce = typeof window === 'undefined' ? props.nonce : '';
|
||||
|
||||
return (
|
||||
<ThemeProvider nonce={nonce} attribute="class" enableSystem forcedTheme={forcedTheme}>
|
||||
|
||||
Reference in New Issue
Block a user