Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions Fixes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,68 @@
## 1. useAdvancedForms.tsx

### Line 115-120: Add stateManager to dependencies

```typescript
useEffect(() => {
stateManager.initializeDependencies(config.fields, config.conditionalLogic || []);
}, [config.fields, config.conditionalLogic, stateManager]);
```

### Line 137-138: Add missing dependency or add eslint-disable

After line 137, add:

```typescript
// eslint-disable-next-line react-hooks/exhaustive-deps
```

### Line 162-163: Add eslint-disable

After line 162:

```typescript
// eslint-disable-next-line react-hooks/exhaustive-deps
```

### Line 292-293: Add eslint-disable

After line 292:

```typescript
// eslint-disable-next-line react-hooks/exhaustive-deps
```

## 2. useAdvancedSearch.tsx

### Line 48-51: Add setHistory to dependencies

```typescript
}, []);
```

Change to:

```typescript
}, []); // Intentionally empty - only runs on mount
```

### Line 54-57: Fix by adding eslint-disable

After line 54:

```typescript
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [history]); // Only depend on history to avoid infinite loop
```

### Line 148-150: Add query and addToHistory

Already correct

## 3. useDataVisualization.tsx

### Line 96: Add missing dependencies to websocketUrl effect

```typescript
return () => {
socket?.disconnect();
Expand All @@ -60,11 +74,14 @@ return () => {

## 4. useInternationalization.tsx

### Line 68-73: Add setLanguage to dependencies
### Line 68-73: Add setLanguage to dependencies

```typescript
}, []); // Run once on mount
```

Change to:

```typescript
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); // Intentionally run once on mount, setLanguage is stable
Expand All @@ -73,10 +90,11 @@ Change to:
## 5. useSearchFilters.tsx

### Line 27-65: Add searchParams to dependency array

```typescript
}, [filters, pathname, router, searchParams]);
```

---

**For the remaining files**, I'll provide you with a complete corrected version.
**For the remaining files**, I'll provide you with a complete corrected version.
34 changes: 17 additions & 17 deletions apply-hooks-fixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ const fixes = [
}, [config, stateManager]);`,
replace: ` useEffect(() => {
stateManager.initializeDependencies(config.fields, config.conditionalLogic || []);
}, [config.fields, config.conditionalLogic, stateManager]);`
}, [config.fields, config.conditionalLogic, stateManager]);`,
},
{
search: ` return () => subscription.unsubscribe();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [stateManager, validateOnChange, autoSave, formId, onFieldChange]);`,
replace: ` return () => subscription.unsubscribe();
}, [stateManager, validateOnChange, autoSave, formId, onFieldChange, autoSaveManager]);`
}, [stateManager, validateOnChange, autoSave, formId, onFieldChange, autoSaveManager]);`,
},
{
search: ` return () => {
Expand All @@ -29,7 +29,7 @@ const fixes = [
replace: ` return () => {
subscription.unsubscribe();
};
}, [autoSave, autoSaveInterval, formId, autoSaveManager, loadDraft]);`
}, [autoSave, autoSaveInterval, formId, autoSaveManager, loadDraft]);`,
},
{
search: ` } finally {
Expand All @@ -40,9 +40,9 @@ const fixes = [
replace: ` } finally {
setIsSubmitting(false);
}
}, [stateManager, validateForm, onSubmit, formState.values, autoSave, clearDraft]);`
}
]
}, [stateManager, validateForm, onSubmit, formState.values, autoSave, clearDraft]);`,
},
],
},
{
file: 'src/hooks/useAdvancedSearch.tsx',
Expand All @@ -64,9 +64,9 @@ const fixes = [
setHistory(storedHistory);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); // Run only once on mount`
}
]
}, []); // Run only once on mount`,
},
],
},
{
file: 'src/hooks/useInternationalization.tsx',
Expand All @@ -85,19 +85,19 @@ const fixes = [
setLanguage(savedLanguage);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); // Intentionally run once on mount`
}
]
}, []); // Intentionally run once on mount`,
},
],
},
{
file: 'src/hooks/useSearchFilters.tsx',
replacements: [
{
search: ` }, [filters, pathname, router]);`,
replace: ` }, [filters, pathname, router]); // searchParams intentionally excluded - only used for initial state`
}
]
}
replace: ` }, [filters, pathname, router]); // searchParams intentionally excluded - only used for initial state`,
},
],
},
];

fixes.forEach(({ file, replacements }) => {
Expand All @@ -109,4 +109,4 @@ fixes.forEach(({ file, replacements }) => {
console.log(`✅ Fixed: ${file}`);
});

console.log('\n🎉 All fixes applied!');
console.log('\n🎉 All fixes applied!');
Loading
Loading