Срабатывание консоли происходит два раза
Из-за чего компонент два раза отрабатывает?
export const loader: LoaderFunction = async () => {
return []
}
export default function Root() {
let { state } : {state: string} = useLocation()
console.log('state', state)
return (
<>
<div id="sidebar">
<h1>React Router Contacts</h1>
</div>
</>
);
}
const router = createBrowserRouter([
{
path: "/",
element: <Root />,
errorElement: <ErrorPage />,
loader: rootLoader,
children: [
{
path: "contacts/:id",
element: <Contact />,
loader: contactLoader
},
],
},
{
path: "/app",
element: <App />,
errorElement: <ErrorPage />,
}
]);
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<Provider store={store}>
<RouterProvider
router={router}
/>
</Provider>
</React.StrictMode>
)