Fix: Maximum update depth exceeded in NewScrapePage

Wrap handleJobsChange in useCallback to prevent infinite re-renders
caused by onJobsChange dependency changing on every render.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-01-24 13:14:23 +00:00
parent cd9639f3b1
commit eab0b4a7e9

View File

@@ -1,18 +1,19 @@
'use client';
import { useRouter } from 'next/navigation';
import { useCallback } from 'react';
import ScraperTest from '@/components/ScraperTest';
import { useJobs } from '@/contexts/JobsContext';
import { JobStatus } from '@/components/ScraperTest';
export default function NewScrapePage() {
const router = useRouter();
const { addJob, refreshJobs } = useJobs();
const { addJob } = useJobs();
const handleJobsChange = (jobs: JobStatus[]) => {
// Add new jobs to context
const handleJobsChange = useCallback((jobs: JobStatus[]) => {
// Add new jobs to context (addJob handles deduplication)
jobs.forEach(job => addJob(job));
};
}, [addJob]);
const handleSelectReviews = (reviews: unknown[], businessName: string, jobId: string) => {
// Navigate to analytics page for this job