diff --git a/index.html b/index.html index 73bf75c..9ff1543 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Super Quizz + ... document.title = name) + return ( } + element={} > unknown; - key?: string; -}; +type explicit = { + effect: () => unknown + key?: string +} + +type implicit = () => unknown -export function useRunOnce ({ effect, key = 'global' }: useRunOnceProps) { +export type useRunOnceParameters = explicit | implicit + +export function useRunOnce (parameters: useRunOnceParameters) { const triggered = useRef(false) + const { effect, key } = typeof parameters === 'function' + ? { effect: parameters, key: undefined } + : parameters + useEffect(() => { const hasBeenTriggered = key ? sessionStorage.getItem(key) diff --git a/src/view/layouts/Layout.tsx b/src/view/layouts/PublicLayout.tsx similarity index 96% rename from src/view/layouts/Layout.tsx rename to src/view/layouts/PublicLayout.tsx index 9d11ea0..e02dc4e 100644 --- a/src/view/layouts/Layout.tsx +++ b/src/view/layouts/PublicLayout.tsx @@ -3,11 +3,11 @@ import { useTranslation } from 'react-i18next' import { useApp } from '../hooks/useApp.ts' import { useRunOnce } from '../hooks/useRunOnce.ts' -export function Layout () { +export function PublicLayout () { const navigate = useNavigate() const { t } = useTranslation( 'default', - { keyPrefix: 'layouts.root' } + { keyPrefix: 'layouts.public' } ) const { session, auth } = useApp()