Skip to content

Commit

Permalink
chore: Add Routing and RouterLink docs (#11456)
Browse files Browse the repository at this point in the history
* chore: Add Routing and RouterLink docs

* example
  • Loading branch information
olerichter00 authored Jan 30, 2025
1 parent 5023fd3 commit 631c0b7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- [Test on a real device: create a beta](deploy_to_beta.md)
- [Generate a Release build for local testing](generate_a_release_build_for_local_testing.md)
- [Pull Request template](pull_request_template.md)
- [Routing](routing.md)
- [Introduction to animations in Eigen](intro_animations_in_eigen)

### Beta
Expand Down
19 changes: 19 additions & 0 deletions docs/routing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Routing

All app routes are specified in [routes.tsx].

## RouterLink Component

The [RouterLink] component wraps `Touchable` and enables navigation to a specific route when pressed. It also supports prefetching the route as it comes into view.

```typescript
<RouterLink to="/my-route" navigationProps={{ filters: ["my-filter"]}} onPress={onPress}>
{children}
</RouterLink>
```

Alternatively, [navigate] can be used to programmatically navigate to a given route.

[routes.tsx]: /src/app/Navigation/routes.tsx
[RouterLink]: /src/app/system/navigation/RouterLink.tsx
[navigate]: /src/app/system/navigation/navigate.ts
4 changes: 4 additions & 0 deletions src/app/system/navigation/RouterLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ interface RouterLinkProps {
to?: string | null | undefined
}

/**
* Wrapper component around <Touchable> that navigates to a specified route (the `to` prop) when pressed.
* `RouterLink` also supports prefetching the route when it comes into view.
*/
export const RouterLink: React.FC<RouterLinkProps & TouchableProps> = ({
disablePrefetch,
to,
Expand Down

0 comments on commit 631c0b7

Please sign in to comment.