expo-router 0.0.24 → 0.0.25
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/build/ContextNavigationContainer.d.ts +2 -0
- package/build/ContextNavigationContainer.d.ts.map +1 -1
- package/build/ContextNavigationContainer.js +8 -26
- package/build/ContextNavigationContainer.js.map +1 -1
- package/build/index.d.ts +2 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/link/Link.d.ts +4 -0
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js +10 -0
- package/build/link/Link.js.map +1 -1
- package/build/link/useLink.d.ts.map +1 -1
- package/build/link/useLink.js +11 -14
- package/build/link/useLink.js.map +1 -1
- package/build/link/useLoadedNavigation.d.ts +6 -0
- package/build/link/useLoadedNavigation.d.ts.map +1 -0
- package/build/link/useLoadedNavigation.js +38 -0
- package/build/link/useLoadedNavigation.js.map +1 -0
- package/build/useCurrentRoute.d.ts +4 -7
- package/build/useCurrentRoute.d.ts.map +1 -1
- package/build/useCurrentRoute.js +6 -6
- package/build/useCurrentRoute.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NavigationContainer } from "@react-navigation/native";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { useRootNavigation } from "./useCurrentRoute";
|
|
3
4
|
declare type NavigationContainerProps = React.ComponentProps<typeof NavigationContainer>;
|
|
4
5
|
export declare function useNavigationContainerContext(): [Partial<import("@react-navigation/native").NavigationContainerProps & {
|
|
5
6
|
theme?: import("@react-navigation/native").Theme | undefined;
|
|
@@ -22,6 +23,7 @@ export declare function useNavigationContainerContext(): [Partial<import("@react
|
|
|
22
23
|
export declare function ContextNavigationContainer(props: NavigationContainerProps): JSX.Element;
|
|
23
24
|
export declare function RootContainer({ documentTitle, fallback, onReady, initialState, onStateChange, onUnhandledAction, theme, }: Omit<NavigationContainerProps, "independent" | "ref" | "children" | "linking">): null;
|
|
24
25
|
export declare namespace RootContainer {
|
|
26
|
+
var useRef: typeof useRootNavigation;
|
|
25
27
|
var getRef: () => import("@react-navigation/native").NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;
|
|
26
28
|
}
|
|
27
29
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextNavigationContainer.d.ts","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ContextNavigationContainer.d.ts","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAqB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAIzE,aAAK,wBAAwB,GAAG,KAAK,CAAC,cAAc,CAClD,OAAO,mBAAmB,CAC3B,CAAC;AASF,wBAAgB,6BAA6B;;;;;;;;;;;;;;;;aAQ5C;AAED,8GAA8G;AAC9G,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,wBAAwB,eAsBzE;AAyBD,wBAAgB,aAAa,CAAC,EAC5B,aAAa,EACb,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,KAAK,GACN,EAAE,IAAI,CACL,wBAAwB,EACxB,aAAa,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAC/C,QAwBA;yBAnCe,aAAa"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createNavigationContainerRef,
|
|
2
|
-
import React
|
|
1
|
+
import { createNavigationContainerRef, NavigationContainer, } from "@react-navigation/native";
|
|
2
|
+
import React from "react";
|
|
3
3
|
import { useLinkingConfig } from "./getLinkingConfig";
|
|
4
4
|
import SplashModule from "./splash";
|
|
5
|
-
import {
|
|
5
|
+
import { RootNavigationRef, useRootNavigation } from "./useCurrentRoute";
|
|
6
6
|
const navigationRef = createNavigationContainerRef();
|
|
7
7
|
const NavigationContainerContext = React.createContext([{}, function () { }]);
|
|
8
8
|
export function useNavigationContainerContext() {
|
|
@@ -27,34 +27,15 @@ export function ContextNavigationContainer(props) {
|
|
|
27
27
|
] },
|
|
28
28
|
React.createElement(InternalContextNavigationContainer, null)));
|
|
29
29
|
}
|
|
30
|
-
function trimQuery(pathname) {
|
|
31
|
-
const queryIndex = pathname.indexOf("?");
|
|
32
|
-
if (queryIndex !== -1) {
|
|
33
|
-
return pathname.substring(0, queryIndex);
|
|
34
|
-
}
|
|
35
|
-
return pathname;
|
|
36
|
-
}
|
|
37
30
|
function InternalContextNavigationContainer(props) {
|
|
38
31
|
const [contextProps] = useNavigationContainerContext();
|
|
39
|
-
const [
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const currentRoute = findFocusedRoute(state);
|
|
43
|
-
setState({
|
|
44
|
-
pathname: trimQuery(currentRoute?.path ?? "/"),
|
|
45
|
-
query: currentRoute?.params ?? {},
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}, [setState]);
|
|
49
|
-
return (React.createElement(VirtualRouteContext.Provider, { value: state },
|
|
32
|
+
const [isReady, setReady] = React.useState(false);
|
|
33
|
+
const ref = React.useMemo(() => (isReady ? navigationRef : null), [isReady]);
|
|
34
|
+
return (React.createElement(RootNavigationRef.Provider, { value: { ref } },
|
|
50
35
|
React.createElement(NavigationContainer, { ...props, ...contextProps, ref: navigationRef, onReady: () => {
|
|
51
36
|
contextProps.onReady?.();
|
|
52
37
|
SplashModule?.hideAsync();
|
|
53
|
-
|
|
54
|
-
onStateChange(initialState);
|
|
55
|
-
}, onStateChange: (state) => {
|
|
56
|
-
contextProps.onStateChange?.(state);
|
|
57
|
-
onStateChange(state);
|
|
38
|
+
setReady(true);
|
|
58
39
|
} })));
|
|
59
40
|
}
|
|
60
41
|
export function RootContainer({ documentTitle, fallback, onReady, initialState, onStateChange, onUnhandledAction, theme, }) {
|
|
@@ -80,6 +61,7 @@ export function RootContainer({ documentTitle, fallback, onReady, initialState,
|
|
|
80
61
|
]);
|
|
81
62
|
return null;
|
|
82
63
|
}
|
|
64
|
+
RootContainer.useRef = useRootNavigation;
|
|
83
65
|
/** Get the root navigation container ref. */
|
|
84
66
|
RootContainer.getRef = () => {
|
|
85
67
|
return navigationRef;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextNavigationContainer.js","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,
|
|
1
|
+
{"version":3,"file":"ContextNavigationContainer.js","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"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","sourcesContent":["import {\n createNavigationContainerRef,\n NavigationContainer,\n} from \"@react-navigation/native\";\nimport React from \"react\";\n\nimport { useLinkingConfig } from \"./getLinkingConfig\";\nimport SplashModule from \"./splash\";\nimport { RootNavigationRef, useRootNavigation } from \"./useCurrentRoute\";\n\nconst navigationRef = createNavigationContainerRef();\n\ntype NavigationContainerProps = React.ComponentProps<\n typeof NavigationContainer\n>;\n\nconst NavigationContainerContext = React.createContext<\n [\n Partial<NavigationContainerProps>,\n (props: Partial<NavigationContainerProps>) => void\n ]\n>([{}, function () {}]);\n\nexport function useNavigationContainerContext() {\n const context = React.useContext(NavigationContainerContext);\n if (!context) {\n throw new Error(\n \"useNavigationContainerContext must be used within a NavigationContainerContext\"\n );\n }\n return context;\n}\n\n/** react-navigation `NavigationContainer` with automatic `linking` prop generated from the routes context. */\nexport function ContextNavigationContainer(props: NavigationContainerProps) {\n const [state, setState] = React.useState<Partial<NavigationContainerProps>>(\n {}\n );\n\n const linking = useLinkingConfig();\n console.log(\"linking\", linking);\n\n return (\n <NavigationContainerContext.Provider\n value={[\n {\n ...props,\n linking,\n ...state,\n },\n setState,\n ]}\n >\n <InternalContextNavigationContainer />\n </NavigationContainerContext.Provider>\n );\n}\n\nfunction InternalContextNavigationContainer(props: object) {\n const [contextProps] = useNavigationContainerContext();\n const [isReady, setReady] = React.useState(false);\n\n const ref = React.useMemo(() => (isReady ? navigationRef : null), [isReady]);\n\n return (\n <RootNavigationRef.Provider value={{ ref }}>\n {/* @ts-expect-error: children are required */}\n <NavigationContainer\n {...props}\n {...contextProps}\n ref={navigationRef}\n onReady={() => {\n contextProps.onReady?.();\n SplashModule?.hideAsync();\n setReady(true);\n }}\n />\n </RootNavigationRef.Provider>\n );\n}\n\nexport function RootContainer({\n documentTitle,\n fallback,\n onReady,\n initialState,\n onStateChange,\n onUnhandledAction,\n theme,\n}: Omit<\n NavigationContainerProps,\n \"independent\" | \"ref\" | \"children\" | \"linking\"\n>) {\n const [, setProps] = useNavigationContainerContext();\n\n React.useEffect(() => {\n setProps({\n documentTitle,\n fallback,\n onReady,\n initialState,\n onStateChange,\n onUnhandledAction,\n theme,\n });\n }, [\n documentTitle,\n fallback,\n onReady,\n initialState,\n onStateChange,\n onUnhandledAction,\n theme,\n ]);\n\n return null;\n}\n\nRootContainer.useRef = useRootNavigation;\n\n/** Get the root navigation container ref. */\nRootContainer.getRef = () => {\n return navigationRef;\n};\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { useFocusEffect } from "@react-navigation/native";
|
|
1
2
|
export { ErrorBoundaryProps } from "./views/Try";
|
|
2
3
|
export { Stack } from "./layouts/Stack";
|
|
3
4
|
export { NativeStack } from "./layouts/NativeStack";
|
|
@@ -8,7 +9,7 @@ export { ExpoRoot } from "./views/Root";
|
|
|
8
9
|
export { Unmatched } from "./views/Unmatched";
|
|
9
10
|
export { ErrorBoundary } from "./views/ErrorBoundary";
|
|
10
11
|
export { Layout, Children } from "./views/Layout";
|
|
11
|
-
export { Link } from "./link/Link";
|
|
12
|
+
export { Link, Redirect } from "./link/Link";
|
|
12
13
|
export { useLink } from "./link/useLink";
|
|
13
14
|
export { RootContainer } from "./ContextNavigationContainer";
|
|
14
15
|
export * as Linking from "./link/linking";
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// export { useRoutes } from "./Route";
|
|
2
2
|
// export { useScreens } from "./useScreens";
|
|
3
|
+
export { useFocusEffect } from "@react-navigation/native";
|
|
3
4
|
export { Stack } from "./layouts/Stack";
|
|
4
5
|
export { NativeStack } from "./layouts/NativeStack";
|
|
5
6
|
export { Tabs } from "./layouts/Tabs";
|
|
@@ -9,7 +10,7 @@ export { ExpoRoot } from "./views/Root";
|
|
|
9
10
|
export { Unmatched } from "./views/Unmatched";
|
|
10
11
|
export { ErrorBoundary } from "./views/ErrorBoundary";
|
|
11
12
|
export { Layout, Children } from "./views/Layout";
|
|
12
|
-
export { Link } from "./link/Link";
|
|
13
|
+
export { Link, Redirect } from "./link/Link";
|
|
13
14
|
export { useLink } from "./link/useLink";
|
|
14
15
|
export { RootContainer } from "./ContextNavigationContainer";
|
|
15
16
|
import * as Linking_1 from "./link/linking";
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,6CAA6C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,6CAA6C;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;2BAEpC,gBAAgB;sBAA7B,OAAO","sourcesContent":["// export { useRoutes } from \"./Route\";\n// export { useScreens } from \"./useScreens\";\n\nexport { useFocusEffect } from \"@react-navigation/native\";\nexport { ErrorBoundaryProps } from \"./views/Try\";\n\nexport { Stack } from \"./layouts/Stack\";\nexport { NativeStack } from \"./layouts/NativeStack\";\nexport { Tabs } from \"./layouts/Tabs\";\nexport { Drawer } from \"./layouts/Drawer\";\nexport { withLayoutContext } from \"./layouts/withLayoutContext\";\n\nexport { ExpoRoot } from \"./views/Root\";\nexport { Unmatched } from \"./views/Unmatched\";\nexport { ErrorBoundary } from \"./views/ErrorBoundary\";\n\nexport { Layout, Children } from \"./views/Layout\";\nexport { Link, Redirect } from \"./link/Link\";\nexport { useLink } from \"./link/useLink\";\nexport { RootContainer } from \"./ContextNavigationContainer\";\n\nexport * as Linking from \"./link/linking\";\n"]}
|
package/build/link/Link.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ declare type Props = {
|
|
|
13
13
|
} & (TextProps & {
|
|
14
14
|
children: React.ReactNode;
|
|
15
15
|
});
|
|
16
|
+
/** Redirects to the href as soon as the component is mounted. */
|
|
17
|
+
export declare function Redirect({ href }: {
|
|
18
|
+
href: Href;
|
|
19
|
+
}): null;
|
|
16
20
|
/**
|
|
17
21
|
* Component to render link to another screen using a path.
|
|
18
22
|
* Uses an anchor tag on the web.
|
package/build/link/Link.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAQ,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAQ,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAY,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAe,MAAM,QAAQ,CAAC;AAI3C,aAAK,KAAK,GAAG;IACX,2CAA2C;IAC3C,IAAI,EAAE,IAAI,CAAC;IAGX,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,OAAO,CAAC,EAAE,CACR,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,qBAAqB,KACvE,IAAI,CAAC;CACX,GAAG,CAAC,SAAS,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,CAAC;AAEhD,iEAAiE;AACjE,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,QAMhD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,s7BAAmC,CAAC"}
|
package/build/link/Link.js
CHANGED
|
@@ -2,10 +2,20 @@
|
|
|
2
2
|
// `to` / `action` support removed.
|
|
3
3
|
import { Text } from "@bacons/react-views";
|
|
4
4
|
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { useFocusEffect } from "@react-navigation/native";
|
|
5
6
|
import * as React from "react";
|
|
6
7
|
import { Platform } from "react-native";
|
|
7
8
|
import { resolveHref } from "./href";
|
|
9
|
+
import { useLink } from "./useLink";
|
|
8
10
|
import useLinkToPathProps from "./useLinkToPathProps";
|
|
11
|
+
/** Redirects to the href as soon as the component is mounted. */
|
|
12
|
+
export function Redirect({ href }) {
|
|
13
|
+
const link = useLink();
|
|
14
|
+
useFocusEffect(() => {
|
|
15
|
+
link.replace(href);
|
|
16
|
+
});
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
9
19
|
/**
|
|
10
20
|
* Component to render link to another screen using a path.
|
|
11
21
|
* Uses an anchor tag on the web.
|
package/build/link/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,mCAAmC;AACnC,OAAO,EAAE,IAAI,EAAa,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAyB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAQ,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAkBtD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAErD,SAAS,cAAc,CACrB,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAS,EAC1C,GAA6B;IAE7B,6CAA6C;IAC7C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEpE,MAAM,KAAK,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,CACd,CAA0E,EAC1E,EAAE;QACF,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;SACnB;QACD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,KAAK,CAAC,aAAa;IACxB,0CAA0C;IAC1C,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EACrB;QACE,GAAG;QACH,GAAG,KAAK;QACR,GAAG,IAAI;QACP,GAAG,QAAQ,CAAC,MAAM,CAAC;YACjB,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAS;YAChC,OAAO,EAAE,EAAE,OAAO,EAAE;SACrB,CAAC;KACH,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx with `href` and `replace` support added and\n// `to` / `action` support removed.\nimport { Text, TextProps } from \"@bacons/react-views\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport * as React from \"react\";\nimport { GestureResponderEvent, Platform } from \"react-native\";\n\nimport { Href, resolveHref } from \"./href\";\nimport useLinkToPathProps from \"./useLinkToPathProps\";\n\ntype Props = {\n /** Add a property which is familiar to */\n href: Href;\n\n // TODO(EvanBacon): This may need to be extracted for React Native style support.\n /** Forward props to child component. Useful for custom buttons. */\n asChild?: boolean;\n\n /** Should replace the current screen without adding to the history. */\n replace?: boolean;\n\n onPress?: (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => void;\n} & (TextProps & { children: React.ReactNode });\n\n/**\n * Component to render link to another screen using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.href Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.asChild Forward props to child component. Useful for custom buttons.\n * @param props.children Child elements to render the content.\n */\nexport const Link = React.forwardRef(ExpoRouterLink);\n\nfunction ExpoRouterLink(\n { href, replace, asChild, ...rest }: Props,\n ref: React.ForwardedRef<Text>\n) {\n // TODO: Auto use router's client-side event.\n const resolvedHref = React.useMemo(() => resolveHref(href), [href]);\n\n const props = useLinkToPathProps({ href: resolvedHref, replace });\n\n const onPress = (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n if (\"onPress\" in rest) {\n rest.onPress?.(e);\n }\n props.onPress(e);\n };\n\n return React.createElement(\n // @ts-expect-error: slot is not type-safe\n asChild ? Slot : Text,\n {\n ref,\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n }\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,mCAAmC;AACnC,OAAO,EAAE,IAAI,EAAa,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAyB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAQ,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAkBtD,iEAAiE;AACjE,MAAM,UAAU,QAAQ,CAAC,EAAE,IAAI,EAAkB;IAC/C,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,cAAc,CAAC,GAAG,EAAE;QAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAErD,SAAS,cAAc,CACrB,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAS,EAC1C,GAA6B;IAE7B,6CAA6C;IAC7C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEpE,MAAM,KAAK,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,CACd,CAA0E,EAC1E,EAAE;QACF,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;SACnB;QACD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,KAAK,CAAC,aAAa;IACxB,0CAA0C;IAC1C,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EACrB;QACE,GAAG;QACH,GAAG,KAAK;QACR,GAAG,IAAI;QACP,GAAG,QAAQ,CAAC,MAAM,CAAC;YACjB,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAS;YAChC,OAAO,EAAE,EAAE,OAAO,EAAE;SACrB,CAAC;KACH,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx with `href` and `replace` support added and\n// `to` / `action` support removed.\nimport { Text, TextProps } from \"@bacons/react-views\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useFocusEffect } from \"@react-navigation/native\";\nimport * as React from \"react\";\nimport { GestureResponderEvent, Platform } from \"react-native\";\n\nimport { Href, resolveHref } from \"./href\";\nimport { useLink } from \"./useLink\";\nimport useLinkToPathProps from \"./useLinkToPathProps\";\n\ntype Props = {\n /** Add a property which is familiar to */\n href: Href;\n\n // TODO(EvanBacon): This may need to be extracted for React Native style support.\n /** Forward props to child component. Useful for custom buttons. */\n asChild?: boolean;\n\n /** Should replace the current screen without adding to the history. */\n replace?: boolean;\n\n onPress?: (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => void;\n} & (TextProps & { children: React.ReactNode });\n\n/** Redirects to the href as soon as the component is mounted. */\nexport function Redirect({ href }: { href: Href }) {\n const link = useLink();\n useFocusEffect(() => {\n link.replace(href);\n });\n return null;\n}\n\n/**\n * Component to render link to another screen using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.href Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.asChild Forward props to child component. Useful for custom buttons.\n * @param props.children Child elements to render the content.\n */\nexport const Link = React.forwardRef(ExpoRouterLink);\n\nfunction ExpoRouterLink(\n { href, replace, asChild, ...rest }: Props,\n ref: React.ForwardedRef<Text>\n) {\n // TODO: Auto use router's client-side event.\n const resolvedHref = React.useMemo(() => resolveHref(href), [href]);\n\n const props = useLinkToPathProps({ href: resolvedHref, replace });\n\n const onPress = (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n if (\"onPress\" in rest) {\n rest.onPress?.(e);\n }\n props.onPress(e);\n };\n\n return React.createElement(\n // @ts-expect-error: slot is not type-safe\n asChild ? Slot : Text,\n {\n ref,\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n }\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLink.d.ts","sourceRoot":"","sources":["../../src/link/useLink.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLink.d.ts","sourceRoot":"","sources":["../../src/link/useLink.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAK3C,wBAAgB,OAAO,IAAI;IACzB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,OAAO,WAAW,CAAC;CAC3B,CA2BA"}
|
package/build/link/useLink.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMemo } from "react";
|
|
1
|
+
import { useCallback } from "react";
|
|
3
2
|
import { resolveHref } from "./href";
|
|
4
3
|
import { useLinkToPath } from "./useLinkToPath";
|
|
4
|
+
import { useLoadedNavigation } from "./useLoadedNavigation";
|
|
5
5
|
// Wraps useLinkTo to provide an API which is similar to the Link component.
|
|
6
6
|
export function useLink() {
|
|
7
|
+
const pending = useLoadedNavigation();
|
|
7
8
|
const linkTo = useLinkToPath();
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
replace
|
|
15
|
-
const href = resolveHref(url);
|
|
16
|
-
linkTo(href, "REPLACE");
|
|
17
|
-
},
|
|
18
|
-
back: () => navigation?.goBack(),
|
|
9
|
+
const push = useCallback((url) => pending(() => linkTo(resolveHref(url))), [pending, linkTo]);
|
|
10
|
+
const replace = useCallback((url) => pending(() => linkTo(resolveHref(url), "REPLACE")), [pending, linkTo]);
|
|
11
|
+
const back = useCallback(() => pending((navigation) => navigation.goBack()), [pending]);
|
|
12
|
+
return {
|
|
13
|
+
push,
|
|
14
|
+
back,
|
|
15
|
+
replace,
|
|
19
16
|
parse: resolveHref,
|
|
20
17
|
// TODO(EvanBacon): add `pathname`, `query`, maybe `reload`
|
|
21
18
|
// TODO(EvanBacon): add `canGoBack` but maybe more like a `hasContext`
|
|
22
|
-
}
|
|
19
|
+
};
|
|
23
20
|
}
|
|
24
21
|
//# sourceMappingURL=useLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLink.js","sourceRoot":"","sources":["../../src/link/useLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useLink.js","sourceRoot":"","sources":["../../src/link/useLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAQ,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,4EAA4E;AAC5E,MAAM,UAAU,OAAO;IAMrB,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IACtC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAE/B,MAAM,IAAI,GAAG,WAAW,CACtB,CAAC,GAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EACtD,CAAC,OAAO,EAAE,MAAM,CAAC,CAClB,CAAC;IAEF,MAAM,OAAO,GAAG,WAAW,CACzB,CAAC,GAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC,EACjE,CAAC,OAAO,EAAE,MAAM,CAAC,CAClB,CAAC;IAEF,MAAM,IAAI,GAAG,WAAW,CACtB,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAClD,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,OAAO;QACL,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,KAAK,EAAE,WAAW;QAClB,2DAA2D;QAC3D,sEAAsE;KACvE,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback } from \"react\";\n\nimport { Href, resolveHref } from \"./href\";\nimport { useLinkToPath } from \"./useLinkToPath\";\nimport { useLoadedNavigation } from \"./useLoadedNavigation\";\n\n// Wraps useLinkTo to provide an API which is similar to the Link component.\nexport function useLink(): {\n push: (href: Href) => void;\n replace: (href: Href) => void;\n back: () => void;\n parse: typeof resolveHref;\n} {\n const pending = useLoadedNavigation();\n const linkTo = useLinkToPath();\n\n const push = useCallback(\n (url: Href) => pending(() => linkTo(resolveHref(url))),\n [pending, linkTo]\n );\n\n const replace = useCallback(\n (url: Href) => pending(() => linkTo(resolveHref(url), \"REPLACE\")),\n [pending, linkTo]\n );\n\n const back = useCallback(\n () => pending((navigation) => navigation.goBack()),\n [pending]\n );\n\n return {\n push,\n back,\n replace,\n parse: resolveHref,\n // TODO(EvanBacon): add `pathname`, `query`, maybe `reload`\n // TODO(EvanBacon): add `canGoBack` but maybe more like a `hasContext`\n };\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NavigationProp } from "@react-navigation/native";
|
|
2
|
+
declare type GenericNavigation = NavigationProp<ReactNavigation.RootParamList>;
|
|
3
|
+
/** Returns a callback which is invoked when the navigation state has loaded. */
|
|
4
|
+
export declare function useLoadedNavigation(): (fn: (navigation: GenericNavigation) => void) => void;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=useLoadedNavigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLoadedNavigation.d.ts","sourceRoot":"","sources":["../../src/link/useLoadedNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAKzE,aAAK,iBAAiB,GAAG,cAAc,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;AAEvE,gFAAgF;AAChF,wBAAgB,mBAAmB,sBA8Bb,iBAAiB,KAAK,IAAI,UAU/C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useNavigation } from "@react-navigation/native";
|
|
2
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
3
|
+
import { RootContainer } from "../ContextNavigationContainer";
|
|
4
|
+
/** Returns a callback which is invoked when the navigation state has loaded. */
|
|
5
|
+
export function useLoadedNavigation() {
|
|
6
|
+
const root = RootContainer.useRef();
|
|
7
|
+
const navigation = useNavigation();
|
|
8
|
+
const isMounted = useRef(true);
|
|
9
|
+
const pending = useRef([]);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
isMounted.current = true;
|
|
12
|
+
return () => {
|
|
13
|
+
isMounted.current = false;
|
|
14
|
+
};
|
|
15
|
+
}, []);
|
|
16
|
+
const flush = useCallback(() => {
|
|
17
|
+
if (isMounted.current) {
|
|
18
|
+
const pendingCallbacks = pending.current;
|
|
19
|
+
pending.current = [];
|
|
20
|
+
pendingCallbacks.forEach((callback) => {
|
|
21
|
+
callback(navigation);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}, [navigation]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (root) {
|
|
27
|
+
flush();
|
|
28
|
+
}
|
|
29
|
+
}, [root, flush]);
|
|
30
|
+
const push = useCallback((fn) => {
|
|
31
|
+
pending.current.push(fn);
|
|
32
|
+
if (root) {
|
|
33
|
+
flush();
|
|
34
|
+
}
|
|
35
|
+
}, [flush, root]);
|
|
36
|
+
return push;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=useLoadedNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLoadedNavigation.js","sourceRoot":"","sources":["../../src/link/useLoadedNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAI9D,gFAAgF;AAChF,MAAM,UAAU,mBAAmB;IACjC,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC;IACpC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,OAAO,GAAG,MAAM,CAA8C,EAAE,CAAC,CAAC;IAExE,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;QACzB,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,IAAI,SAAS,CAAC,OAAO,EAAE;YACrB,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;YACzC,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;YACrB,gBAAgB,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACpC,QAAQ,CAAC,UAAU,CAAC,CAAC;YACvB,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,EAAE;YACR,KAAK,EAAE,CAAC;SACT;IACH,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAElB,MAAM,IAAI,GAAG,WAAW,CACtB,CAAC,EAA2C,EAAE,EAAE;QAC9C,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,IAAI,IAAI,EAAE;YACR,KAAK,EAAE,CAAC;SACT;IACH,CAAC,EACD,CAAC,KAAK,EAAE,IAAI,CAAC,CACd,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { NavigationProp, useNavigation } from \"@react-navigation/native\";\nimport { useCallback, useEffect, useRef } from \"react\";\n\nimport { RootContainer } from \"../ContextNavigationContainer\";\n\ntype GenericNavigation = NavigationProp<ReactNavigation.RootParamList>;\n\n/** Returns a callback which is invoked when the navigation state has loaded. */\nexport function useLoadedNavigation() {\n const root = RootContainer.useRef();\n const navigation = useNavigation();\n const isMounted = useRef(true);\n const pending = useRef<((navigation: GenericNavigation) => void)[]>([]);\n\n useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n const flush = useCallback(() => {\n if (isMounted.current) {\n const pendingCallbacks = pending.current;\n pending.current = [];\n pendingCallbacks.forEach((callback) => {\n callback(navigation);\n });\n }\n }, [navigation]);\n\n useEffect(() => {\n if (root) {\n flush();\n }\n }, [root, flush]);\n\n const push = useCallback(\n (fn: (navigation: GenericNavigation) => void) => {\n pending.current.push(fn);\n if (root) {\n flush();\n }\n },\n [flush, root]\n );\n\n return push;\n}\n"]}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
+
import { NavigationContainerRefWithCurrent } from "@react-navigation/native";
|
|
1
2
|
import React from "react";
|
|
2
|
-
export declare const
|
|
3
|
-
|
|
4
|
-
query: Record<string, any>;
|
|
3
|
+
export declare const RootNavigationRef: React.Context<{
|
|
4
|
+
ref: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList> | null;
|
|
5
5
|
}>;
|
|
6
|
-
export declare function
|
|
7
|
-
pathname: string | null;
|
|
8
|
-
query: Record<string, any>;
|
|
9
|
-
};
|
|
6
|
+
export declare function useRootNavigation(): NavigationContainerRefWithCurrent<ReactNavigation.RootParamList> | null;
|
|
10
7
|
//# sourceMappingURL=useCurrentRoute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrentRoute.d.ts","sourceRoot":"","sources":["../src/useCurrentRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"useCurrentRoute.d.ts","sourceRoot":"","sources":["../src/useCurrentRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,iBAAiB;SACvB,kCAAkC,gBAAgB,aAAa,CAAC,GAAG,IAAI;EAC7D,CAAC;AAMlB,wBAAgB,iBAAiB,4EAQhC"}
|
package/build/useCurrentRoute.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export const
|
|
2
|
+
export const RootNavigationRef = React.createContext({ ref: null });
|
|
3
3
|
if (process.env.NODE_ENV !== "production") {
|
|
4
|
-
|
|
4
|
+
RootNavigationRef.displayName = "RootNavigationRef";
|
|
5
5
|
}
|
|
6
|
-
export function
|
|
7
|
-
const context = React.useContext(
|
|
6
|
+
export function useRootNavigation() {
|
|
7
|
+
const context = React.useContext(RootNavigationRef);
|
|
8
8
|
if (!context) {
|
|
9
|
-
throw new Error("
|
|
9
|
+
throw new Error("useRootNavigation must be used within a NavigationContainerContext");
|
|
10
10
|
}
|
|
11
|
-
return context;
|
|
11
|
+
return context.ref;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=useCurrentRoute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrentRoute.js","sourceRoot":"","sources":["../src/useCurrentRoute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrentRoute.js","sourceRoot":"","sources":["../src/useCurrentRoute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAEjD,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AAElB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAC;CACrD;AAED,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;KACH;IACD,OAAO,OAAO,CAAC,GAAG,CAAC;AACrB,CAAC","sourcesContent":["import { NavigationContainerRefWithCurrent } from \"@react-navigation/native\";\nimport React from \"react\";\n\nexport const RootNavigationRef = React.createContext<{\n ref: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList> | null;\n}>({ ref: null });\n\nif (process.env.NODE_ENV !== \"production\") {\n RootNavigationRef.displayName = \"RootNavigationRef\";\n}\n\nexport function useRootNavigation() {\n const context = React.useContext(RootNavigationRef);\n if (!context) {\n throw new Error(\n \"useRootNavigation must be used within a NavigationContainerContext\"\n );\n }\n return context.ref;\n}\n"]}
|