Skip to content

Commit a417996

Browse files
authored
fix: flushSync support (#13755)
fix: clone request if we have to read the body
1 parent f2b4258 commit a417996

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/react-router/lib/rsc/browser.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from "react";
2+
import * as ReactDOM from "react-dom";
23

34
import { RouterProvider } from "../components";
45
import type { DataRouteMatch, DataRouteObject } from "../context";
@@ -80,7 +81,7 @@ export function createCallServer({
8081
const promise = new Promise<void>((resolve, rejectFn) => {
8182
reject = rejectFn;
8283
});
83-
84+
8485
const unsubscribe = window.__router.subscribe(({ navigation }) => {
8586
if (navigation.state === "idle") {
8687
unsubscribe();
@@ -530,7 +531,7 @@ export function RSCHydratedRouter({
530531

531532
return (
532533
<FrameworkContext.Provider value={frameworkContext}>
533-
<RouterProvider router={router} />
534+
<RouterProvider router={router} flushSync={ReactDOM.flushSync} />
534535
</FrameworkContext.Provider>
535536
);
536537
}

packages/react-router/lib/rsc/server.rsc.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ async function processServerAction(
276276
}
277277

278278
if (request.method === "POST") {
279+
const clone = request.clone();
279280
const formData = await request.formData();
280281
if (Array.from(formData.keys()).some((k) => k.startsWith("$ACTION_"))) {
281282
if (!decodeFormAction) {
@@ -296,6 +297,9 @@ async function processServerAction(
296297
revalidationRequest: getRevalidationRequest(),
297298
};
298299
}
300+
return {
301+
revalidationRequest: clone,
302+
};
299303
}
300304
}
301305

0 commit comments

Comments
 (0)