Replies: 1 comment
-
I've also created a stack overflow question on this if anybody is curious |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm wondering if anybody has used the react-i18next library with the latest React Router v6.
In React Router
v6
the suggested router iscreateBrowserRouter()
which needs to know all the routes ahead of time. My file structure has the routes in theindex.ts
of each page's directory and in thatindex.ts
file I'm defining some meta data about the page.The meta data is a
const
and includes the name of the page which is wrapped ini18n.t()
which is causing warnings about using the function before the library has been initialized. I'm wondering if there are any best practices that should be followed in scenarios like this.I've considered changing the
const metadata = [...]
to a function likegetPageData(i18n)
.I've considered changing the routes so each page has a
getRoutes()
function that is executed after i18n has been initialized. And then I would callgetAllRoute()
in themain.ts
wherecreateBrowserRouter()
is defined.I'm hoping somebody has done this before or can maybe point me in the right direction?
The pseudo file structure/code looks like similar to this (I didn't define all the objects properly):
main.tsx
routes.ts
page1/index.ts
Beta Was this translation helpful? Give feedback.
All reactions