Could not find ConvexClient in Next.js
So I have something like this:
_app.tsx
parentComponent.tsx
OtherComponent.tsx
Child.tsx
I get if I add the useMutation hook in the child
6 Replies
Is this App Router Next.js, in the app directory?
Nope, pages
for both the threads im in - its pages
Any interesting React libraries you're using, like react-three-fiber? One issue we've seen is context not working between different React renderers, so any library that uses a custom React renderer needs more setup.
Also curious if passing the call ack down works, if so sounds like there's some context barrier in the react tree or some different way that useMutation is being imported
YES
i passed a callback function down and that worked for me yes
Alright, this is a React issue. https://github.com/pmndrs/react-three-fiber/issues/262
You can use
useConvex()
to grab the convex client from a parent and then use another ConvexProvider inside the Canvas component, they call this a "bridge" in these issues. Like
GitHub
Using context inside child elements of Canvas · Issue #262 · pmndrs...
Hi, 👋 I wanted to create a simple "store" for my app with createContext. Unexpectedly, I found out that I can't access my context within the Canvas element. const StateContext = creat...
👀
That was VERY helpful thank you very much Tom
the reason i didnt do this right away was
that parent component i was talking about is INSIDE the canvas already
so if it works there already it was weird it wudnt work on any of its children