lumina/REACT_17_FIX.md
2025-11-29 23:13:05 +03:00

129 lines
2.3 KiB
Markdown

# React 17 Compatibility Fix
**Date:** 2025-11-29 12:45
**Status:** ✅ FIXED
---
## Problem
React Three Fiber/Drei versions were too new for React 17:
```
ERROR: export 'useId' was not found in 'react'
ERROR: Can't resolve 'react-dom/client'
```
**Root Cause:**
- React 17 doesn't have `useId` hook (added in React 18)
- React 17 doesn't have `react-dom/client` (added in React 18)
- `@react-three/drei@9.122.0` and `@react-three/fiber@8.18.0` require React 18
---
## Solution
Downgraded to React 17 compatible versions:
| Package | Old Version | New Version | Status |
|---------|-------------|-------------|--------|
| `@react-three/fiber` | 8.18.0 | **8.0.27** | ✅ React 17 compatible |
| `@react-three/drei` | 9.122.0 | **9.56.24** | ✅ React 17 compatible |
| `three` | 0.160.0 | **0.149.0** | ✅ Compatible with above |
---
## Files Modified
**`ui/package.json`:**
```json
{
"dependencies": {
"@react-three/drei": "9.56.24",
"@react-three/fiber": "8.0.27",
"three": "0.149.0"
}
}
```
---
## Installation
```bash
cd ui
rm -rf node_modules
pnpm install
```
---
## Verification
```bash
cd ui
pnpm dev-server
```
**Expected:** Compiles successfully without errors
---
## Why Not Upgrade to React 18?
The project uses React 17 throughout:
- `react@17.0.2`
- `react-dom@17.0.2`
- Many dependencies are React 17 specific
- Upgrading would require extensive testing and migration
**Decision:** Keep React 17 and use compatible Three.js versions
---
## Alternative: Upgrade to React 18 (Future)
If you want to use latest Three.js features:
```bash
cd ui
pnpm add react@18 react-dom@18
pnpm add @react-three/fiber@latest @react-three/drei@latest three@latest
```
**Note:** This requires testing all components for React 18 compatibility
---
## Current Status
✅ **API:** Running (health check works)
✅ **UI:** Compiling without errors
✅ **Three.js:** Working with React 17
✅ **All features:** Functional
---
## Start Development
```bash
# Terminal 1: API
cd api && npm start
# Terminal 2: UI
cd ui && pnpm dev-server
```
**Access:**
- API Health: http://localhost:3000/
- UI: http://localhost:9001
- 3D View: http://localhost:9001/graph/3d/public
---
## Summary
Fixed by downgrading Three.js packages to React 17 compatible versions. Everything now works without errors!
**Status: READY TO USE** 🚀