Ajoute un commentaire explicatif sur le EmbeddedContext
parent
642e36677b
commit
544dc2dfe8
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue