From 9f164a6327bc4d04840f028802b6a01329c6d66d Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Fri, 14 Apr 2023 15:02:08 -0400 Subject: [PATCH] Add relative routing example to README --- packages/router/README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/router/README.md b/packages/router/README.md index 385ced7c36..bd931f830c 100644 --- a/packages/router/README.md +++ b/packages/router/README.md @@ -17,12 +17,19 @@ A Router instance can be created using `createRouter`: // including history listeners and kicking off the initial data fetch let router = createRouter({ // Required properties - routes, // Routes array - history, // History instance + routes: [{ + path: '/', + loader: ({ request, params }) => { /* ... */ }, + children: [{ + path: 'home', + loader: ({ request, params }) => { /* ... */ }, + }] + }, + history: createBrowserHistory(), // Optional properties basename, // Base path - mapRouteProperties, // Map function framework-agnostic routes to framework-aware routes + mapRouteProperties, // Map framework-agnostic routes to framework-aware routes future, // Future flags hydrationData, // Hydration data if using server-side-rendering }).initialize(); @@ -83,6 +90,11 @@ router.navigate("/page", { formMethod: "post", formData, }); + +// Relative routing from a source routeId +router.navigate("../../somewhere", { + fromRouteId: "active-route-id", +}); ``` ### Fetchers