how to create a Protected Route if I wrote route in the way: I am use 6.4.3 version react-router-dom.
const router = createBrowserRouter([
{
path: "/",
element: <Root />,
errorElement: <ErrorPage />,
loader: rootLoader(queryClient),
action: rootAction(queryClient),
children: [
{
index: true,
element: <Index />
},
{
path: "contacts/:contactId",
element: <Contact />,
loader: contactLoader(queryClient),
action: contactAction(queryClient),
},
],
},
],
);