Skip to content

Commit

Permalink
modification of csp nonce handling to avoid hydration error
Browse files Browse the repository at this point in the history
  • Loading branch information
Julienng committed May 2, 2024
1 parent 1a0ae30 commit 70b6c49
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/@react-aria/i18n/src/server.tsx
Expand Up @@ -33,8 +33,10 @@ export function PackageLocalizationProvider(props: PackageLocalizationProviderPr
return null;
}

let {locale, strings} = props;
return <script nonce={props.nonce} dangerouslySetInnerHTML={{__html: getPackageLocalizationScript(locale, strings)}} />;
let {nonce, locale, strings} = props;
// suppressHydrationWarning is necessary because the browser
// remove the nonce parameter from the DOM before hydration
return <script nonce={typeof window === 'undefined' ? nonce : ''} suppressHydrationWarning dangerouslySetInnerHTML={{__html: getPackageLocalizationScript(locale, strings)}} />;
}

/**
Expand Down

0 comments on commit 70b6c49

Please sign in to comment.