Skip to content

Commit

Permalink
Do not pass unneeded disableTransitionOnChange and children props…
Browse files Browse the repository at this point in the history
… in `<ThemeScript />` (pacocoursey#270)

Update index.tsx
  • Loading branch information
Dimitri POSTOLOV authored Mar 13, 2024
1 parent 3cfbbed commit 5f8669a
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions next-themes/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,13 @@ const Theme = ({
<ThemeScript
{...{
forcedTheme,
disableTransitionOnChange,
storageKey,
attribute,
enableSystem,
enableColorScheme,
storageKey,
themes,
defaultTheme,
attribute,
value,
children,
themes,
nonce
}}
/>
Expand All @@ -179,8 +177,8 @@ const ThemeScript = React.memo(
value,
themes,
nonce
}: ThemeProviderProps & { defaultTheme: string }) => {
const scriptProps = [
}: Omit<ThemeProviderProps, 'children'> & { defaultTheme: string }) => {
const scriptArgs = JSON.stringify([
attribute,
storageKey,
defaultTheme,
Expand All @@ -189,15 +187,13 @@ const ThemeScript = React.memo(
value,
enableSystem,
enableColorScheme
]
]).slice(1, -1)

return (
<script
suppressHydrationWarning
nonce={typeof window === 'undefined' ? nonce : ''}
dangerouslySetInnerHTML={{
__html: `(${script.toString()})(${JSON.stringify(scriptProps).slice(1, -1)})`
}}
dangerouslySetInnerHTML={{ __html: `(${script.toString()})(${scriptArgs})` }}
/>
)
}
Expand Down

0 comments on commit 5f8669a

Please sign in to comment.