From 544dc2dfe84c273915076782390d40a49a01f5d6 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Fri, 5 Nov 2021 09:50:28 +0100 Subject: [PATCH] Ajoute un commentaire explicatif sur le EmbeddedContext --- .../source/components/utils/embeddedContext.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mon-entreprise/source/components/utils/embeddedContext.tsx b/mon-entreprise/source/components/utils/embeddedContext.tsx index 020f2c652..acbf840fe 100644 --- a/mon-entreprise/source/components/utils/embeddedContext.tsx +++ b/mon-entreprise/source/components/utils/embeddedContext.tsx @@ -1,6 +1,14 @@ import { createContext, ReactNode, useContext, useState } from 'react' -import { useEffect } from 'react' +/* + Instead of relying on a contextual Provider that activates the + EmbeddedContext only to iframe paths, we use a global root Context, that + is modified by side effect when we detect that we are inside an iframe path. + + Its value will not be changed again during the user journey. This means that + the documentation pages will still be displayed with the Embedded style (no + header, no footer) +*/ const IsEmbeddedContext = createContext<[boolean, (b: boolean) => void]>([ false, () => { @@ -19,10 +27,12 @@ export function IsEmbeddedProvider({ children }: { children: ReactNode }) { ) } +/* +This hook activates the embedded style for the whole application, indefinitely. +*/ export function useSetEmbedded() { const setEmbedded = useContext(IsEmbeddedContext)[1] setEmbedded(true) - // useEffect(() => setEmbedded(true), [setEmbedded]) } export function useIsEmbedded() {