You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Server-side streaming with useSWR appears to work, in that you can see the data fetched on the server and sent through script tags later on. However, it isn't currently set up to share data between the server and client, causing a client-side fetch to happen in addition to the server-side fetch. Since nothing breaks or warns, it looks like this is fully working when it's not.
Expected Behavior
As suggested by @devknollhere, useSWR should throw a friendly error when the the suspense flag is on and it tries to suspend on the server, so folks know this isn't yet implemented fully.
One use case that this breaks is when doing rendering in some "simulated" runtime on the server, like react-ssr-prepass, which depends on useSWR() throwing these promises so that it can wait for them to resolve and use the fetched data to pre-populate the data cache. Unfortunately, this now errors out with React 18 on the server. There is no "fallback" data to specify, since the point of using react-ssr-prepass is to populate that fallback data cache.
Would you consider a flag for SWR config that would preserve the previous behavior, throwing the promise even on React 18 + server?
Bug report
Description / Observed Behavior
Server-side streaming with useSWR appears to work, in that you can see the data fetched on the server and sent through script tags later on. However, it isn't currently set up to share data between the server and client, causing a client-side fetch to happen in addition to the server-side fetch. Since nothing breaks or warns, it looks like this is fully working when it's not.
Expected Behavior
As suggested by @devknoll here, useSWR should throw a friendly error when the the
suspense
flag is on and it tries to suspend on the server, so folks know this isn't yet implemented fully.Repro Steps / Code Example
index.js
profile.jsx
concurrentFeatures
flag.The text was updated successfully, but these errors were encountered: