React works in "vite dev" but not "vite preview" #15027
Unanswered
mschersten
asked this question in
Q&A
Replies: 1 comment
-
I have the same problem and could not find the solution. May I ask if the problem is resolved? |
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'll provide some more detail, but the summary of this is that while my React application works fine with "vite dev" it does not work correctly when deployed to my cloud environment or running from the build package with "vite preview".
The issue is coming up when using @auth0/auth0-react and react-router-dom (using <RouterProvider/> and createBrowserRouter() ). The useAuth0() hook uses authentication context, and requires that the component be nested inside of the <Auth0Provider/>. When running with "vite dev" everything works fine and the context is available everywhere I expect it. However with "vite preview" the context is not available inside of an <Outlet/> component in a child path in my router, and I receive an error in the console of "you forgot to wrap your component in <Auth0Provider>".
This seems related to some other issues that have been raised, but I'm not clear on how to apply those to this situtation.
#7335
#14198
#14692
Any advice on how to find the cause of the problem?
Beta Was this translation helpful? Give feedback.
All reactions