Outlet Flashcards

(1 cards)

1
Q

Outlet

A

children для реакт дома, если они не обязательны. Outlet - компонент из пакета react-router, используемый в родительских элементах маршрута для визуализации дочерних элементов маршрута. Позволяет отобразить вложенный пользовательский интерфейс при отрисовке дочерних маршрутов.
import { Navigate, Outlet } from “react-router”
import { ReactNode } from “react”
import { Path } from “@/common/components/routing/Routing.tsx”

type Props = {
children?: ReactNode
isAllowed: boolean
redirectPath?: string
}

export const ProtectedRoutes = ({ children, isAllowed, redirectPath = Path.Login }: Props) => {
if (!isAllowed) {
return <Navigate to={redirectPath} />
}

return children ?? <Outlet></Outlet>
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly