useMutation in Context+Provider infinite calls
Hi all, thanks in advance for your time.
I'm using react-router & tanstack query.
I need a POST to get fired off upon App initialisation and I figured I could do that using a
createContext
and provider to then be able to access it a bit deeper down easily, that'd be useful. I am completely unable to get this to work or understand why I am getting infinite re-renders. I have tried everything chat gippity is suggesting and have googled as much as possible.
In AuthContext.tsx:
1 Reply
exotic-emeraldOP•3mo ago
main.tsx:
App.tsx
This is my first React project, please bear with. Really appreciate any help, been wrestling with this all day.
If I call
mutation.mutateAsync
in the if
statement I do get somewhat of a correct behaviour, but the issue is twofold:
- The docs say this should be awaited, it returns a promise.
- It gets called once on my onboarding form but three times on my 404 Page.