From d8da763fdf6c0ff1ab3fd526780a8243c96589f7 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Thu, 27 Jun 2024 20:16:51 +0200 Subject: [PATCH] readme for usePathParams --- packages/rescript-relay-router/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/rescript-relay-router/README.md b/packages/rescript-relay-router/README.md index 15e5727..0321eb6 100644 --- a/packages/rescript-relay-router/README.md +++ b/packages/rescript-relay-router/README.md @@ -441,6 +441,17 @@ This would do 2 things: - This route will only match if `memberStatus` is one of the values in the provided list (`active`, `inactive` or `deleted`). - The type of `memberStatus` will be a polyvariant `[#active | #inactive | #deleted]`. +### Accessing path params via a hook + +You can access the path params for a route via the `usePathParams` hook. It'll return the path params if you're currently on that route. + +```rescript +switch Routes.Organization.Members.Route.usePathParams() { +| Some({slug}) => Console.log("Organization slug: " ++ slug) +| None => Console.log("Woops, not on the expected route.") +} +``` + ## Advanced Here's a few more advanced things you can utilize the router for.