diff --git a/worklenz-frontend/src/App.tsx b/worklenz-frontend/src/App.tsx index d80023f9..c5753f6b 100644 --- a/worklenz-frontend/src/App.tsx +++ b/worklenz-frontend/src/App.tsx @@ -21,7 +21,7 @@ import { Language } from './features/i18n/localesSlice'; import logger from './utils/errorLogger'; import { SuspenseFallback } from './components/suspense-fallback/suspense-fallback'; -const App: React.FC<{ children: React.ReactNode }> = ({ children }) => { +const App: React.FC<{ children?: React.ReactNode }> = ({ children }) => { const themeMode = useAppSelector(state => state.themeReducer.mode); const language = useAppSelector(state => state.localesReducer.lng); diff --git a/worklenz-frontend/src/index.tsx b/worklenz-frontend/src/index.tsx index cf2c161c..3822bb97 100644 --- a/worklenz-frontend/src/index.tsx +++ b/worklenz-frontend/src/index.tsx @@ -1,3 +1,6 @@ +// Import React polyfill first to ensure React is available globally +import './utils/react-polyfill'; + import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; diff --git a/worklenz-frontend/src/utils/dnd-kit-wrapper.ts b/worklenz-frontend/src/utils/dnd-kit-wrapper.ts new file mode 100644 index 00000000..5918f3f4 --- /dev/null +++ b/worklenz-frontend/src/utils/dnd-kit-wrapper.ts @@ -0,0 +1,12 @@ +import React from 'react'; + +// Ensure React is available globally before any @dnd-kit imports +if (typeof globalThis !== 'undefined') { + (globalThis as any).React = React; +} + +// Re-export @dnd-kit utilities with React dependency assured +export * from '@dnd-kit/core'; +export * from '@dnd-kit/sortable'; +export * from '@dnd-kit/modifiers'; +export * from '@dnd-kit/utilities'; \ No newline at end of file diff --git a/worklenz-frontend/src/utils/react-polyfill.ts b/worklenz-frontend/src/utils/react-polyfill.ts new file mode 100644 index 00000000..bc0a14c8 --- /dev/null +++ b/worklenz-frontend/src/utils/react-polyfill.ts @@ -0,0 +1,12 @@ +import React from 'react'; + +// Polyfill React hooks globally to prevent undefined errors in dependencies +if (typeof window !== 'undefined') { + // Ensure React is available globally + (window as any).React = React; +} + +// Also ensure it's available in globalThis for ES modules +if (typeof globalThis !== 'undefined') { + (globalThis as any).React = React; +} \ No newline at end of file