-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fait un rechargement complet de la page en cas d'erreur de chargement…
… dynamique d'un composant
- Loading branch information
1 parent
5a2475b
commit 743acad
Showing
25 changed files
with
83 additions
and
24 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
app.territoiresentransitions.react/src/app/pages/Auth/RecoverLandingPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
app.territoiresentransitions.react/src/app/pages/Auth/RegisterPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
app.territoiresentransitions.react/src/app/pages/Auth/ResetPasswordPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
app.territoiresentransitions.react/src/app/pages/Profil/ProfilPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...esentransitions.react/src/app/pages/ToutesLesCollectivites/ToutesLesCollectivitesPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
app.territoiresentransitions.react/src/app/pages/collectivite/Accueil/AccueilPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...sentransitions.react/src/app/pages/collectivite/BibliothequeDocs/BibliothequeDocsPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ritoiresentransitions.react/src/app/pages/collectivite/Historique/JournalActivitePage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...territoiresentransitions.react/src/app/pages/collectivite/Indicateurs/IndicateursPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ions.react/src/app/pages/collectivite/ParcoursLabellisation/ParcoursLabellisationPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...sentransitions.react/src/app/pages/collectivite/PersoReferentiel/PersoReferentielPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
.../src/app/pages/collectivite/PersoReferentielThematique/PersoReferentielThematiquePage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...transitions.react/src/app/pages/collectivite/PlansActions/FicheAction/FicheActionPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ions.react/src/app/pages/collectivite/PlansActions/ParcoursCreationPlan/CreerPlanPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...s.react/src/app/pages/collectivite/PlansActions/ParcoursCreationPlan/ImporterPlanPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ions.react/src/app/pages/collectivite/PlansActions/ParcoursCreationPlan/SelectionPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...entransitions.react/src/app/pages/collectivite/PlansActions/PlanAction/PlanActionPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...rritoiresentransitions.react/src/app/pages/collectivite/PlansActions/PlansActionsPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...iresentransitions.react/src/app/pages/collectivite/PlansActions/Synthese/SynthesePage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ns.react/src/app/pages/collectivite/PlansActions/Synthese/SyntheseVue/SyntheseVuePage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
app.territoiresentransitions.react/src/app/pages/collectivite/Referentiels/ActionPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...rritoiresentransitions.react/src/app/pages/collectivite/Referentiels/ReferentielsPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
app.territoiresentransitions.react/src/app/pages/collectivite/Users/MembresPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
app.territoiresentransitions.react/src/ui/shared/actions/ActionPreuvePanel/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {ComponentType, lazy as originalLazy} from 'react'; | ||
|
||
type ImportComponent = () => Promise<{default: ComponentType<any>}>; | ||
|
||
const FORCE_REFRESH = 'force-refresh'; | ||
|
||
// Encapsule la fonction `React.lazy` pour faire un rechargement complet de la | ||
// page en cas d'erreur de chargement dynamique d'un composant, et ce afin | ||
// d'éviter les `ChunkLoadError` lors des mises à jour du front. | ||
// Ref: https://gist.github.com/raphael-leger/4d703dea6c845788ff9eb36142374bdb#file-lazywithretry-js | ||
export const lazy = (importComponent: ImportComponent) => | ||
originalLazy((async () => { | ||
// vérifie si on a déjà forcé le rechargement complet | ||
const isPageHasBeenForceRefreshed = JSON.parse( | ||
localStorage.getItem(FORCE_REFRESH) || 'false' | ||
); | ||
|
||
try { | ||
// essaye de charger le composant | ||
const component = await importComponent(); | ||
|
||
localStorage.setItem(FORCE_REFRESH, 'false'); | ||
|
||
return component; | ||
} catch (error) { | ||
// en cas d'erreur on essaye de faire un rechargement complet de la page | ||
// si ça n'a pas déjà été tenté | ||
if (!isPageHasBeenForceRefreshed) { | ||
localStorage.setItem(FORCE_REFRESH, 'true'); | ||
return document.location.reload(); | ||
} | ||
|
||
throw error; | ||
} | ||
}) as ImportComponent); |