Skip to content

Commit

Permalink
fix hasLoaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Boutzi committed Oct 23, 2024
1 parent 118c238 commit 3ec4328
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions components/ProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function ProgressBar({ onComplete }: ProgressBarProps) {
} else {
setTimeout(() => {
setVisible(false);
onComplete(); // Appeler la fonction de complétion ici
onComplete();
}, 200);
}
};
Expand All @@ -42,7 +42,7 @@ export function ProgressBar({ onComplete }: ProgressBarProps) {
return () => {
cancelAnimationFrame(animationFrameId);
};
}, [onComplete]); // Ajoutez onComplete comme dépendance
}, [onComplete]);

return (
visible && (
Expand Down
6 changes: 5 additions & 1 deletion context/LoaderContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ export const useLoader = (): LoaderContextType => {

export const LoaderProvider = ({ children }: { children: ReactNode }) => {
const [isLoading, setIsLoading] = useState<boolean>(false);
const [hasLoaded, setHasLoaded] = useState<boolean>(false);

const showLoader = () => {
setIsLoading(true);
if (!hasLoaded) {
setIsLoading(true);
}
};

const hideLoader = () => {
const timeout = setTimeout(() => {
setIsLoading(false);
setHasLoaded(true);
}, 2000);
return () => clearTimeout(timeout);
};
Expand Down

0 comments on commit 3ec4328

Please sign in to comment.