From dfc66df542b286865a8668c2a735cd4bbd0069e5 Mon Sep 17 00:00:00 2001
From: Jacob Ebey
Date: Mon, 29 Apr 2024 10:30:19 -0700
Subject: [PATCH] fix: allow undefined to be resolved with ``
---
.changeset/heavy-lies-ring.md | 5 ++++
.../__tests__/data-memory-router-test.tsx | 29 +++++++++++++++++++
packages/react-router/lib/components.tsx | 4 +--
3 files changed, 36 insertions(+), 2 deletions(-)
create mode 100644 .changeset/heavy-lies-ring.md
diff --git a/.changeset/heavy-lies-ring.md b/.changeset/heavy-lies-ring.md
new file mode 100644
index 0000000000..f758c28dc0
--- /dev/null
+++ b/.changeset/heavy-lies-ring.md
@@ -0,0 +1,5 @@
+---
+"react-router": patch
+---
+
+allow undefined to be resolved with ``
diff --git a/packages/react-router/__tests__/data-memory-router-test.tsx b/packages/react-router/__tests__/data-memory-router-test.tsx
index 4a4826dd2c..db9dd488ad 100644
--- a/packages/react-router/__tests__/data-memory-router-test.tsx
+++ b/packages/react-router/__tests__/data-memory-router-test.tsx
@@ -3089,6 +3089,35 @@ describe("createMemoryRouter", () => {
`);
});
+ it("can render raw resolved to undefined promises with ", async () => {
+ let dfd = createDeferred();
+
+ let { container } = render(
+ Loading...
}>
+ {(data) => {String(data)}
}
+
+ );
+
+ console.log(getHtml(container));
+ expect(getHtml(container)).toMatchInlineSnapshot(`
+ ""
+ `);
+
+ dfd.resolve(undefined);
+ await waitFor(() => screen.getByText("undefined"));
+ expect(getHtml(container)).toMatchInlineSnapshot(`
+ ""
+ `);
+ });
+
it("can render raw resolved promises with ", async () => {
let dfd = createDeferred();
diff --git a/packages/react-router/lib/components.tsx b/packages/react-router/lib/components.tsx
index 918bc34d39..958cb5a773 100644
--- a/packages/react-router/lib/components.tsx
+++ b/packages/react-router/lib/components.tsx
@@ -590,9 +590,9 @@ class AwaitErrorBoundary extends React.Component<
// Already tracked promise - check contents
promise = resolve;
status =
- promise._error !== undefined
+ "_error" in promise
? AwaitRenderStatus.error
- : promise._data !== undefined
+ : "_data" in promise
? AwaitRenderStatus.success
: AwaitRenderStatus.pending;
} else {