File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -25,12 +25,15 @@ export const links: Route.LinksFunction = () => [
2525] 
2626
2727export  function  Layout ( {  children } : {  children : React . ReactNode  } )  { 
28+   const  useReactScan  =  import . meta?. env ?. DEV  ||  false 
29+ 
2830  return  ( 
2931    < html  lang = "en"  suppressHydrationWarning > 
3032      < head > 
3133        < meta  charSet = "utf-8"  /> 
3234        < meta  name = "viewport"  content = "width=device-width, initial-scale=1"  /> 
3335        < script  dangerouslySetInnerHTML = { {  __html : themeDetectJs  } }  /> 
36+         { useReactScan  &&  < script  crossOrigin = "anonymous"  src = "//unpkg.com/react-scan/dist/auto.global.js"  /> } 
3437        < Meta  /> 
3538        < Links  /> 
3639      </ head > 
Original file line number Diff line number Diff line change 22  // 
33  // This script detects the user's preferred color scheme and updates the theme accordingly. 
44  // 
5-   // Example usage (in React Router root.tsx): 
6-   // 
7-   //  import  themeDetectJs from '@/lib/theme-detect.js?raw'  
8-   //  // in the Layout component add this in the head, before  other scripts to avoid UI flashing:  
9-   //  <script dangerouslySetInnerHTML={{ __html: themeDetectJs }} />  
5+   // Example usage (in React Router app/ root.tsx, or Next.js app/layout .tsx): 
6+   // - Import the script as raw text: `import themeDetectJs from '@/lib/theme-detect.js?raw'`  
7+   // - In the Layout component add `<script dangerouslySetInnerHTML={{ __html:  themeDetectJs }} />` in the head  
8+   //   before stylesheets and  other scripts to avoid UI flashing 
9+   // - In the Layout component add `suppressHydrationWarning` to the html tag to avoid hydration errors  
1010  // 
1111  function  getPreferredColorScheme ( )  { 
1212    if  ( window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches )  { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments