This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hello, in a team we've started a project using react, firebase and react-router v6.10 with the new object router. Does anyone have any example on how to use the firebase auth and react-router with the loader functions in order to have the user loaded before the page is rendered. Some sort of protected route examples. I know how to do it on older react-router versions, but with this one I just can't.
We have the standard
const { user } = useFirebaseContext()
But when the page is reloaded, it returns a null first and therefore an error.
This is the object notation with the new react-router v6.10
import React from "react"; import ReactDOM from "react-dom/client"; import { createBrowserRouter, RouterProvider, } from "react-router-dom"; import "./index.css"; const router = createBrowserRouter([ { path: "/", element: <div>Hello world!</div>, }, ]); ReactDOM.createRoot(document.getElementById("root")).render( <React.StrictMode> <RouterProvider router={router} /> </React.StrictMode> );
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnreactj...