i have this hook:
import { useState } from 'react';
export const useRefreshReports = () => {
const [shouldRefreshReports, setShouldRefreshReports] = useState(false);
function RefreshReportsTrigger() {
setShouldRefreshReports(!shouldRefreshReports);
}
return {
RefreshReportsTrigger,
shouldRefreshReports,
};
};
and I have a modal that manage the upload of a report and when the modal closes it triggers this refreshReports Trigger on a button:
const { RefreshReportsTrigger } = useRefreshReports();
...
<button
className="flex h-10 w-full items-center justify-center rounded-oht-100 border-oht-25 border-oht-brand-p-400 bg-oht-brand-p-400 py-oht-150 pl-oht-250 pr-oht-300"
onClick={() => {
RefreshReportsTrigger();
handleClose();
}}
>
and im using the shouldRefreshReports variable to refresh on another component using a useEffect()
const { shouldRefreshReports } = useRefreshReports();
useEffect(() => {...
}, [accesstoken, page, shouldRefreshReports]
For some reason I dont know the value seems to not be updating at all, what could it be?
New contributor
André Tavares is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.