Server Action vs manual fetch #67857
Unanswered
khuezy
asked this question in
App Router
Replies: 1 comment 2 replies
-
|
Right, the way you are calling fetch is a fire and forget kind of thing, whereas, IIRC, the server action, can modify cookies, and stuff, and that in turn would need the application to re-render, but I am honestly guessing a bit, off your experience. Maybe if you use https://react.dev/reference/react/useActionState#noun-labs-1201738-(2) ? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, does server action do anything special under the hood that may cause issues w/ internal states/render?
See:
https://codesandbox.io/p/devbox/dndkit-qdvhnz?file=%2Fapp%2Fdnd%2Fclient.tsx%3A27%2C1-33%2C9
NOTE: since codesandbox has issues w/ the latest react 19 rsc, you want to:
OR download and run it locally.
Context:
I'm using a drag and drop library (dnd-kit). When the drag end, I call a server action:
But the drag element disappears until the server action resolves and then it reappears. When using the regular fetch, this doesn't occur, eg:
Both the server action and the
/api/hellohas a 2 second delay to demonstrate the odd behavior.In the
client.tsxcomponent, I logconsole.log(items);the server action/api call do not cause a rerender, so I'm confused on what's causing the drag element to disappear.Using

Server Actions:Using

fetch('/api/hello')Beta Was this translation helpful? Give feedback.
All reactions