`useConvexAuth()` returns undefined (resolved: two versions of convex package loaded)
After I upgraded to v0.17.1, I had the problem shown in the title. This is my related error report and code:
8 Replies
I use code like this in frontend react
There is such a console error:
The same error happens on
isLoading
Hmm, there was another report related to React Context recently. Mind trying deleting your
node_modules
and reinstalling?@Francismiko What package manager are you using? I haven't been able to reproduce this yet, looking for patterns.
I am using the
Yarn 3.0
version as a package management tool. It is very strange. I have never encountered this error before.😂
No effect, I'm looking for where the error occurs👨💻@Francismiko are you using Clerk for auth?
It's possible that what's happening is two different versions of Convex or React are being loaded, and a hook from one is looking for a React Context from the other.
Also what version of Clerk or auth0 are you using?
@ballingt yep, I'm using
@clerk/clerk-react": ^4.15.3
. This is my root render codeTo debug this I'd try a minimal example first:
where
App
has the useConvexAuth()
call. Based on the error message the component does not have the expected ConvexAuthContext
. Are you using Next.js with Page or App Router? App Router will need 'use client'
to propagate Context (check out our updated quickstarts).Turns out this was an issue with two copies of Convex being loaded (0.17.1 and 0.16.1 in this case) such that the hook and the provider were from different copies of the library.
It's hard to identify exactly this issue in an error message, but we can change the error message to be clearer about not finding the appropriate React context provider.