@rn-tools/navigation 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -534,8 +534,9 @@ This section will cover how to respond to deep links in your app. Deep links usu
534
534
 
535
535
  Once you are able to receive deep links, use the `DeepLinks` component exported from this library to handle them. In this example we will have a basic 3 tab view. We want to response to the link `home/items/:id` by navigating to the home tab and then pushing a detail screen with the corresponding id.
536
536
 
537
- The deep link component takes an array of handlers which are functions that will be invoked when their `path` matches the deep link that was opened. The handler function will receive the params from the deep link - these use the same token syntax as libraries like `react-router` and `express` for path params.
538
-
537
+ The deep link component takes an array of handlers which are functions that will be invoked when their `path` matches the deep link that was opened.
538
+ - Only the first matching handler will be invoked.
539
+ - The handler function will receive the params from the deep link - these use the same token syntax as libraries like `react-router` and `express` for path params.
539
540
 
540
541
  ```tsx
541
542
  import { DeepLinks, navigation, Stack, Tabs } from "@rn-tools/navigation";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rn-tools/navigation",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "main": "./src/index.ts",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -27,12 +27,14 @@ export function DeepLinks<T>({ path, handlers, children }: DeepLinksProps<T>) {
27
27
  }, [handlers]);
28
28
 
29
29
  React.useEffect(() => {
30
- matchers.current.forEach(({ fn, handler }) => {
30
+ for (let matcher of matchers.current) {
31
+ let { fn, handler } = matcher;
31
32
  let match = fn(path);
32
33
  if (match) {
33
- return setImmediate(() => handler(match.params as T));
34
+ setImmediate(() => handler(match.params as T));
35
+ break;
34
36
  }
35
- });
37
+ }
36
38
  }, [path]);
37
39
 
38
40
  return <>{children}</>;