Closed Nohac closed 3 months ago
I don't think you should be able to call server-actions from non-DOM interactions 😅 as what seems to basically be happening is that the connection is closed immediately. It also tries to tell you this
Warning: Can't perform a React state update on a component that hasn't mounted yet. This indicates that you have a side-effect in your render function that asynchronously later calls tries to update the component. Move this work to useEffect instead.
As the server-action will try to update state on a component that doesn't exist yet. We'd probably also have to catch the action into a loading state, not sure whether server-actions are subject to Suspense but if they are then in this case it happens outside of a component and it might be hard for React to figure out where this belongs.
You're right. I was following this guide and it looked like I could use server actions like a normal async function.
Moving from action to a normal api for subsequent fetches, and passing the token from RSC to the provider on initial render made the issues go away.
Describe the bug
I've followed the steps for nextjs appdir. I've added
authExchange
to the non RSC setup, and inaddAuthToOperation
I'm fetching access token from the server using nextjs server action. When I do this, I'm getting the following errors/warnings:Reproduction
https://stackblitz.com/edit/github-1sqstp?file=app%2Fnon-rsc%2Flayout.tsx
Urql version
urql 4.0.6
Validations