Skip to content

Commit

Permalink
feat: mutable route tree (#9996)
Browse files Browse the repository at this point in the history
* initial work + test outline

* wip: addRoute,updateRoute,deleteRoute

* refactor(hmr): internal api for updating routes and revalidating

* refactor: _internalSetRoutes

* test: update method name after rename

* revalidate in tests

* chore: remove data for routes with no loader
test: cover navigation interruption

* add changeset

* Add a couple more tests

* Fix invalid useRouteLoaderData test

* Handle HMR use cases for revalidating fetchers

* Bump bundle

---------

Co-authored-by: Pedro Cattori <pcattori@gmail.com>
Co-authored-by: Matt Brophy <matt@brophy.org>
  • Loading branch information
3 people committed Feb 21, 2023
1 parent bbe4ec5 commit 3eac3a6
Show file tree
Hide file tree
Showing 6 changed files with 561 additions and 61 deletions.
5 changes: 5 additions & 0 deletions .changeset/quick-yaks-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/router": patch
---

Add internal API for custom HMR implementations
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
},
"filesize": {
"packages/router/dist/router.umd.min.js": {
"none": "41.5 kB"
"none": "41.6 kB"
},
"packages/react-router/dist/react-router.production.min.js": {
"none": "13 kB"
Expand Down
3 changes: 3 additions & 0 deletions packages/react-router-dom/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ export function createStaticRouter(
},
_internalFetchControllers: new Map(),
_internalActiveDeferreds: new Map(),
_internalSetRoutes() {
throw msg("_internalSetRoutes");
},
};
}

Expand Down
5 changes: 2 additions & 3 deletions packages/react-router/__tests__/data-memory-router-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,6 @@ describe("<DataMemoryRouter>", () => {
initialEntries={["/foo"]}
hydrationData={{
loaderData: {
layout: null,
foo: "FOO",
},
}}
Expand Down Expand Up @@ -861,7 +860,7 @@ describe("<DataMemoryRouter>", () => {
}

expect(spy).toHaveBeenCalledWith({
layout: null,
layout: undefined,
foo: "FOO",
bar: undefined,
child: undefined,
Expand Down Expand Up @@ -896,7 +895,7 @@ describe("<DataMemoryRouter>", () => {
</div>"
`);
expect(spy).toHaveBeenCalledWith({
layout: null,
layout: undefined,
foo: undefined,
bar: undefined,
child: "CHILD",
Expand Down
Loading

0 comments on commit 3eac3a6

Please sign in to comment.