File tree Expand file tree Collapse file tree 10 files changed +25
-14
lines changed
Expand file tree Collapse file tree 10 files changed +25
-14
lines changed Original file line number Diff line number Diff line change 44 < meta charset ="UTF-8 " />
55 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
66 < title > Beacons</ title >
7- <!-- Prevent "useLayoutEffect does nothing on the server" warning -->
7+ <!-- Fix for React hooks in server environments -->
88 < script >
9- // Polyfill useLayoutEffect for environments that don't support it (like Deno Deploy)
10- if ( typeof window !== 'undefined' ) {
11- window . React = window . React || { } ;
12- window . React . useLayoutEffect = window . React . useEffect || function ( ) { return function ( ) { } ; } ;
13- }
9+ // This needs to run before React is loaded, so React will use these implementations
10+ window . __REACT_WORKAROUND__ = true ;
11+ window . requestAnimationFrame = function ( cb ) { setTimeout ( cb , 0 ) ; } ;
1412 </ script >
1513 </ head >
1614 < body >
Original file line number Diff line number Diff line change 11'use client' ;
22
3- import React , { useEffect } from 'react' ;
3+ import React , { useEffect } from './lib/utils/ react-safe ' ;
44import { TooltipProvider } from '@radix-ui/react-tooltip' ;
55
66// Providers
Original file line number Diff line number Diff line change 1- import * as React from 'react' ;
1+ import * as React from '../../lib/utils/ react-safe ' ;
22import { Slot } from '@radix-ui/react-slot' ;
33import type { VariantProps } from 'class-variance-authority' ;
44
Original file line number Diff line number Diff line change 11'use client' ;
22
3- import * as React from 'react' ;
3+ import * as React from '../../lib/utils/ react-safe ' ;
44import * as DialogPrimitive from '@radix-ui/react-dialog' ;
55import { X } from 'lucide-react' ;
66import { cn } from '@/lib/utils' ;
Original file line number Diff line number Diff line change 1- import * as React from 'react' ;
1+ import * as React from '../../lib/utils/ react-safe ' ;
22import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu' ;
33import { cn } from '@/lib/utils' ;
44
Original file line number Diff line number Diff line change 11'use client' ;
22
3- import * as React from 'react' ;
3+ import * as React from '../../lib/utils/ react-safe ' ;
44import * as LabelPrimitive from '@radix-ui/react-label' ;
55import { cva , type VariantProps } from 'class-variance-authority' ;
66
Original file line number Diff line number Diff line change 11'use client' ;
22
3- import * as React from 'react' ;
3+ import * as React from '../../lib/utils/ react-safe ' ;
44import * as PopoverPrimitive from '@radix-ui/react-popover' ;
55
66import { cn } from '@/lib/utils' ;
Original file line number Diff line number Diff line change 11'use client' ;
22
3- import * as React from 'react' ;
3+ import * as React from '../../lib/utils/ react-safe ' ;
44import * as TooltipPrimitive from '@radix-ui/react-tooltip' ;
55
66import { cn } from '@/lib/utils' ;
Original file line number Diff line number Diff line change 1+ /**
2+ * This file provides safe React hooks that work in both client and server environments.
3+ * Import these hooks instead of directly importing from React when SSR compatibility is needed.
4+ */
5+ import React , { useEffect , useLayoutEffect } from 'react' ;
6+
7+ // Use a safe version of useLayoutEffect that falls back to useEffect in non-browser environments
8+ export const useIsomorphicLayoutEffect =
9+ typeof window !== 'undefined' ? useLayoutEffect : useEffect ;
10+
11+ // Re-export React to ensure consistent usage
12+ export default React ;
13+ export * from 'react' ;
Original file line number Diff line number Diff line change 1- import { StrictMode } from 'react' ;
1+ import { StrictMode } from './lib/utils/ react-safe ' ;
22import { createRoot } from 'react-dom/client' ;
33import './index.css' ;
44import App from './App' ; // Now your App component is the top-level one
You can’t perform that action at this time.
0 commit comments