Skip to content

Commit

Permalink
Updates to static handler for Remix integration (remix-run#9511)
Browse files Browse the repository at this point in the history
* Updates to unstable staticHandler logic for Remix integration

* Add changeset

* bump bundle

* Remove ErrorWithStatus in favor of extended ErrorResponse

* update

* Update changelog
  • Loading branch information
brophdawg11 authored and Gilberto Olivas committed Nov 15, 2022
1 parent bafa17f commit bb53a9f
Show file tree
Hide file tree
Showing 7 changed files with 446 additions and 238 deletions.
6 changes: 6 additions & 0 deletions .changeset/proud-timers-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@remix-run/router": patch
---

- Throw an error if an `action`/`loader` function returns `undefined` as revalidations need to know whether the loader has previously been executed. `undefined` also causes issues during SSR stringification for hydration. You should always ensure you loader/acton return a value, and you may return `null` if you don't wish to return anything.
- Enhanced `ErrorResponse` bodies to contain more descriptive text in internal 403/404/405 scenarios
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
},
"filesize": {
"packages/router/dist/router.umd.min.js": {
"none": "34 kB"
"none": "34.5 kB"
},
"packages/react-router/dist/react-router.production.min.js": {
"none": "12.5 kB"
Expand Down
10 changes: 5 additions & 5 deletions packages/react-router-dom/__tests__/nav-link-active-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ describe("NavLink using a data router", () => {
fireEvent.click(screen.getByText("Link to Bar"));
expect(screen.getByText("Link to Bar").className).toBe("pending");

dfd.resolve();
dfd.resolve(null);
await waitFor(() => screen.getByText("Bar page"));
expect(screen.getByText("Link to Bar").className).toBe("active");
});
Expand Down Expand Up @@ -562,7 +562,7 @@ describe("NavLink using a data router", () => {
"some-pending-classname"
);

dfd.resolve();
dfd.resolve(null);
await waitFor(() => screen.getByText("Bar page"));
expect(screen.getByText("Link to Bar").className).toBe(
"some-active-classname"
Expand Down Expand Up @@ -617,7 +617,7 @@ describe("NavLink using a data router", () => {
"lowercase"
);

dfd.resolve();
dfd.resolve(null);
await waitFor(() => screen.getByText("Bar page"));
expect(screen.getByText("Link to Bar").style.textTransform).toBe(
"uppercase"
Expand Down Expand Up @@ -667,7 +667,7 @@ describe("NavLink using a data router", () => {
fireEvent.click(screen.getByText("Link to Bar (idle)"));
expect(screen.getByText("Link to Bar (loading...)")).toBeDefined();

dfd.resolve();
dfd.resolve(null);
await waitFor(() => screen.getByText("Bar page"));
expect(screen.getByText("Link to Bar (current)")).toBeDefined();
});
Expand Down Expand Up @@ -708,7 +708,7 @@ describe("NavLink using a data router", () => {
fireEvent.click(screen.getByText("Link to Baz"));
expect(screen.getByText("Link to Bar").className).toBe("");

dfd.resolve();
dfd.resolve(null);
await waitFor(() => screen.getByText("Baz page"));
expect(screen.getByText("Link to Bar").className).toBe("");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2713,7 +2713,7 @@ describe("<DataMemoryRouter>", () => {
expect(getAwaitRenderCount()).toBe(3);

// complete /baz navigation
bazDefer.resolve();
bazDefer.resolve(null);
await waitFor(() => screen.getByText("Baz"));
expect(getHtml(container)).toMatchInlineSnapshot(`
"<div
Expand Down
Loading

0 comments on commit bb53a9f

Please sign in to comment.