Skip to content

Commit 7e1370b

Browse files
committed
Document useRoutePath hook
1 parent 4214c6d commit 7e1370b

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Diff for: versioned_docs/version-7.x/use-link-builder.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ title: useLinkBuilder
44
sidebar_label: useLinkBuilder
55
---
66

7-
The `useLinkBuilder` hook returns helpers to build `href` or action based on the linking options. It returns an object with the following properties:
7+
The `useLinkBuilder` hook returns helpers to build `href` or action based on the [`linking` configuration](configuring-links.md). It returns an object with the following properties:
88

99
- [`buildHref`](#buildhref)
1010
- [`buildAction`](#buildaction)
1111

1212
## `buildHref`
1313

14-
The `buildHref` method lets us build a path to use for links for a screen in the current navigator's state. It returns a function that takes `name` and `params` for the screen to focus and returns path based on the [`linking` options](navigation-container.md#linking).
14+
The `buildHref` method lets us build a path to use for links for a screen in the current navigator's state. It returns a function that takes `name` and `params` for the screen to focus and returns path based on the [`linking` configuration](configuring-links.md).
1515

1616
```js
1717
import { useLinkBuilder } from '@react-navigation/native';

Diff for: versioned_docs/version-7.x/use-route-path.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
id: use-route-path
3+
title: useRoutePath
4+
sidebar_label: useRoutePath
5+
---
6+
7+
import Tabs from '@theme/Tabs';
8+
import TabItem from '@theme/TabItem';
9+
10+
The `useRoutePath` hook can be used to get the path of a route based on the [`linking` configuration](configuring-links.md). This can be useful if you need to generate a URL for a specific route in your app to share as a deep link.
11+
12+
## Example
13+
14+
```js
15+
import { useRoutePath } from '@react-navigation/native';
16+
17+
function MyComponent() {
18+
const path = useRoutePath();
19+
20+
// Construct a URL using the path and app's base URL
21+
const url = new URL(path, 'https://example.com');
22+
23+
return <Text>Shareable URL: {url.href}</Text>;
24+
}
25+
```

Diff for: versioned_sidebars/version-7.x-sidebars.json

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"use-focus-effect",
7272
"use-is-focused",
7373
"use-prevent-remove",
74+
"use-route-path",
7475
"use-link-to",
7576
"use-link-props",
7677
"use-link-builder",

0 commit comments

Comments
 (0)