Skip to content

Commit

Permalink
fix(#30): add ability to pass nonce as a prop to the PreventFlashOnWr…
Browse files Browse the repository at this point in the history
…ongTheme script (#31)

Co-authored-by: Alexandru Bereghici <[email protected]>
  • Loading branch information
abereghici and Alexandru Bereghici committed Feb 2, 2024
1 parent 304822b commit f40a6b4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/remix-themes/src/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,15 @@ const clientThemeCode = `
})();
`

export function PreventFlashOnWrongTheme({ssrTheme}: {ssrTheme: boolean}) {
type PreventFlashOnWrongThemeProps = {
ssrTheme: boolean
nonce?: string
}

export function PreventFlashOnWrongTheme({
ssrTheme,
nonce,
}: PreventFlashOnWrongThemeProps) {
const [theme] = useTheme()

return (
Expand All @@ -154,6 +162,7 @@ export function PreventFlashOnWrongTheme({ssrTheme}: {ssrTheme: boolean}) {
// this script to run synchronously before the rest of the document
// is finished loading.
dangerouslySetInnerHTML={{__html: clientThemeCode}}
nonce={nonce}
/>
)}
</>
Expand Down

0 comments on commit f40a6b4

Please sign in to comment.