Skip to content

Commit

Permalink
readme for usePathParams
Browse files Browse the repository at this point in the history
  • Loading branch information
zth committed Jun 27, 2024
1 parent f96f444 commit d8da763
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/rescript-relay-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d8da763

Please sign in to comment.