File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 1+ import { useEffect , useLayoutEffect } from 'react' ;
2+
3+ /**
4+ * A version of useLayoutEffect that works in both browser and SSR environments
5+ * This prevents errors like "Cannot read properties of undefined (reading 'useLayoutEffect')"
6+ */
7+ export const useIsomorphicLayoutEffect =
8+ typeof window !== 'undefined' ? useLayoutEffect : useEffect ;
Original file line number Diff line number Diff line change 1+ // Apply React useLayoutEffect polyfill
2+ if ( typeof window !== 'undefined' ) {
3+ window . React = window . React || { } ;
4+ window . React . useLayoutEffect = window . React . useEffect || function ( ) { return function ( ) { } ; } ;
5+ }
6+
17import { StrictMode } from 'react' ;
28import { createRoot } from 'react-dom/client' ;
39import './index.css' ;
Original file line number Diff line number Diff line change 11/// <reference types="vite/client" />
2+
3+ interface Window {
4+ React ?: {
5+ useLayoutEffect ?: Function ;
6+ useEffect ?: Function ;
7+ } ;
8+ }
You can’t perform that action at this time.
0 commit comments