Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
15 lines
516 B
TypeScript
15 lines
516 B
TypeScript
"use client";
|
|
import { useEffect, useRef } from "react";
|
|
import { useCompanyScope } from "@/app/lib/CompanyScope";
|
|
|
|
/** A different company is a different list: go back to page 1 when the picker changes (not on first render). */
|
|
export function useResetPageOnCompany(setPage: (p: number) => void) {
|
|
const { companyId } = useCompanyScope();
|
|
const last = useRef(companyId);
|
|
useEffect(() => {
|
|
if (last.current === companyId) return;
|
|
last.current = companyId;
|
|
setPage(1);
|
|
}, [companyId, setPage]);
|
|
}
|