Fix re-renders from adding too many dependencies to useEffect (#2123)

Co-authored-by: Alex Hancock <alexhancock@block.xyz>
This commit is contained in:
Zane
2025-04-10 08:54:10 -07:00
committed by GitHub
parent 6b173682e0
commit 4b9cb74402
7 changed files with 10 additions and 23 deletions

View File

@@ -32,7 +32,8 @@ export default function ExtensionsSection() {
useEffect(() => {
fetchExtensions();
}, [fetchExtensions]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const handleExtensionToggle = async (extension: FixedExtensionEntry) => {
// If extension is enabled, we are trying to toggle if off, otherwise on

View File

@@ -43,19 +43,9 @@ export default function ModelsSection({ setView }: ModelsSectionProps) {
}, [read, getProviders]);
useEffect(() => {
// Initial load
loadModelData();
// Set up polling interval to check for changes
const interval = setInterval(() => {
loadModelData();
}, 1000); // Check every second
// Clean up interval on unmount
return () => {
clearInterval(interval);
};
}, [loadModelData]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
<section id="models" className="px-8">

View File

@@ -27,7 +27,7 @@ export default function ModelsBottomBar({ dropdownRef, setView }: ModelsBottomBa
setProvider(modelProvider.provider);
setModel(modelProvider.model);
})();
}, [read, getProviders]);
});
// Add click outside handler
useEffect(() => {

View File

@@ -96,7 +96,7 @@ export const AddModelModal = ({ onClose, setView }: AddModelModalProps) => {
if (attemptedSubmit) {
validateForm();
}
}, [provider, model, attemptedSubmit, validateForm]);
}, [attemptedSubmit, validateForm]);
useEffect(() => {
(async () => {

View File

@@ -99,7 +99,8 @@ export default function DefaultProviderSetupForm({
useEffect(() => {
loadConfigValues();
}, [loadConfigValues]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
// Filter parameters to only show required ones
const requiredParameters = useMemo(() => {

View File

@@ -61,7 +61,8 @@ export function DeepLinkModal({ botConfig: initialBotConfig, onClose }: DeepLink
instructions,
activities,
});
}, [instructions, activities, botConfig]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [instructions, activities]);
// Handle adding a new activity
const handleAddActivity = () => {

View File

@@ -525,12 +525,6 @@ test.describe('Goose App', () => {
// Wait a bit and dump HTML to see structure
await mainWindow.waitForTimeout(1000);
const html = await mainWindow.evaluate(() => document.documentElement.outerHTML);
console.log('Full page HTML after clicking Output:', html);
// Also dump just the response area HTML
const responseHtml = await response.evaluate(el => el.outerHTML);
console.log('Response area HTML:', responseHtml);
// Take screenshot before trying to find content
await mainWindow.screenshot({ path: `test-results/${provider.name.toLowerCase()}-quote-response-debug.png` });