react-router-native 6.26.2-pre.0 → 6.27.0-pre.0
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/CHANGELOG.md +9 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
# `react-router-native`
|
|
2
2
|
|
|
3
|
-
## 6.
|
|
3
|
+
## 6.27.0-pre.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- Updated dependencies:
|
|
8
|
-
- `react-router@6.
|
|
8
|
+
- `react-router@6.27.0-pre.0`
|
|
9
|
+
|
|
10
|
+
## 6.26.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies:
|
|
15
|
+
- `react-router@6.26.2`
|
|
9
16
|
|
|
10
17
|
## 6.26.1
|
|
11
18
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import type { GestureResponderEvent, TouchableHighlightProps } from "react-native";
|
|
3
3
|
import type { To, MemoryRouterProps, NavigateOptions, RelativeRoutingType } from "react-router";
|
|
4
4
|
import URLSearchParams from "@ungap/url-search-params";
|
|
5
|
-
export type { ActionFunction, ActionFunctionArgs, AwaitProps, Blocker, BlockerFunction, DataRouteMatch, DataRouteObject,
|
|
5
|
+
export type { ActionFunction, ActionFunctionArgs, AwaitProps, Blocker, BlockerFunction, DataRouteMatch, DataRouteObject, DataStrategyFunction, DataStrategyFunctionArgs, DataStrategyMatch, DataStrategyResult, ErrorResponse, Fetcher, FutureConfig, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LazyRouteFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathParam, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch, } from "react-router";
|
|
6
6
|
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, replace, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, } from "react-router";
|
|
7
7
|
/** @internal */
|
|
8
8
|
export { UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, UNSAFE_LocationContext, UNSAFE_RouteContext, UNSAFE_useRouteId, } from "react-router";
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../index.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type {\n GestureResponderEvent,\n TouchableHighlightProps,\n} from \"react-native\";\nimport { BackHandler, Linking, TouchableHighlight } from \"react-native\";\nimport type {\n To,\n MemoryRouterProps,\n NavigateOptions,\n RelativeRoutingType,\n} from \"react-router\";\nimport { MemoryRouter, useLocation, useNavigate } from \"react-router\";\n\nimport URLSearchParams from \"@ungap/url-search-params\";\n\n////////////////////////////////////////////////////////////////////////////////\n// RE-EXPORTS\n////////////////////////////////////////////////////////////////////////////////\n\n// Note: Keep in sync with react-router exports!\nexport type {\n ActionFunction,\n ActionFunctionArgs,\n AwaitProps,\n Blocker,\n BlockerFunction,\n DataRouteMatch,\n DataRouteObject,\n unstable_DataStrategyFunction,\n unstable_DataStrategyFunctionArgs,\n unstable_DataStrategyMatch,\n unstable_DataStrategyResult,\n ErrorResponse,\n Fetcher,\n FutureConfig,\n Hash,\n IndexRouteObject,\n IndexRouteProps,\n JsonFunction,\n LazyRouteFunction,\n LayoutRouteProps,\n LoaderFunction,\n LoaderFunctionArgs,\n Location,\n MemoryRouterProps,\n NavigateFunction,\n NavigateOptions,\n NavigateProps,\n Navigation,\n Navigator,\n NonIndexRouteObject,\n OutletProps,\n Params,\n ParamParseKey,\n Path,\n PathMatch,\n Pathname,\n PathParam,\n PathPattern,\n PathRouteProps,\n RedirectFunction,\n RelativeRoutingType,\n RouteMatch,\n RouteObject,\n RouteProps,\n RouterProps,\n RouterProviderProps,\n RoutesProps,\n Search,\n ShouldRevalidateFunction,\n ShouldRevalidateFunctionArgs,\n To,\n UIMatch,\n} from \"react-router\";\nexport {\n AbortedDeferredError,\n Await,\n MemoryRouter,\n Navigate,\n NavigationType,\n Outlet,\n Route,\n Router,\n RouterProvider,\n Routes,\n createMemoryRouter,\n createPath,\n createRoutesFromChildren,\n createRoutesFromElements,\n defer,\n isRouteErrorResponse,\n generatePath,\n json,\n matchPath,\n matchRoutes,\n parsePath,\n redirect,\n redirectDocument,\n replace,\n renderMatches,\n resolvePath,\n useActionData,\n useAsyncError,\n useAsyncValue,\n useBlocker,\n useHref,\n useInRouterContext,\n useLoaderData,\n useLocation,\n useMatch,\n useMatches,\n useNavigate,\n useNavigation,\n useNavigationType,\n useOutlet,\n useOutletContext,\n useParams,\n useResolvedPath,\n useRevalidator,\n useRouteError,\n useRouteLoaderData,\n useRoutes,\n} from \"react-router\";\n\n///////////////////////////////////////////////////////////////////////////////\n// DANGER! PLEASE READ ME!\n// We provide these exports as an escape hatch in the event that you need any\n// routing data that we don't provide an explicit API for. With that said, we\n// want to cover your use case if we can, so if you feel the need to use these\n// we want to hear from you. Let us know what you're building and we'll do our\n// best to make sure we can support you!\n//\n// We consider these exports an implementation detail and do not guarantee\n// against any breaking changes, regardless of the semver release. Use with\n// extreme caution and only if you understand the consequences. Godspeed.\n///////////////////////////////////////////////////////////////////////////////\n\n/** @internal */\nexport {\n UNSAFE_DataRouterContext,\n UNSAFE_DataRouterStateContext,\n UNSAFE_NavigationContext,\n UNSAFE_LocationContext,\n UNSAFE_RouteContext,\n UNSAFE_useRouteId,\n} from \"react-router\";\n\n////////////////////////////////////////////////////////////////////////////////\n// COMPONENTS\n////////////////////////////////////////////////////////////////////////////////\n\nexport interface NativeRouterProps extends MemoryRouterProps {}\n\n/**\n * A `<Router>` that runs on React Native.\n */\nexport function NativeRouter(props: NativeRouterProps) {\n return <MemoryRouter {...props} />;\n}\n\nexport interface LinkProps extends TouchableHighlightProps {\n children?: React.ReactNode;\n onPress?: (event: GestureResponderEvent) => void;\n relative?: RelativeRoutingType;\n replace?: boolean;\n state?: any;\n to: To;\n}\n\n/**\n * A `<TouchableHighlight>` that navigates to a different URL when touched.\n */\nexport function Link({\n onPress,\n relative,\n replace = false,\n state,\n to,\n ...rest\n}: LinkProps) {\n let internalOnPress = useLinkPressHandler(to, { replace, state, relative });\n function handlePress(event: GestureResponderEvent) {\n if (onPress) onPress(event);\n if (!event.defaultPrevented) {\n internalOnPress(event);\n }\n }\n\n return <TouchableHighlight {...rest} onPress={handlePress} />;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// HOOKS\n////////////////////////////////////////////////////////////////////////////////\n\nconst HardwareBackPressEventType = \"hardwareBackPress\";\nconst URLEventType = \"url\";\n\n/**\n * Handles the press behavior for router `<Link>` components. This is useful if\n * you need to create custom `<Link>` components with the same press behavior we\n * use in our exported `<Link>`.\n */\nexport function useLinkPressHandler(\n to: To,\n {\n replace,\n state,\n relative,\n }: {\n replace?: boolean;\n state?: any;\n relative?: RelativeRoutingType;\n } = {}\n): (event: GestureResponderEvent) => void {\n let navigate = useNavigate();\n return function handlePress() {\n navigate(to, { replace, state, relative });\n };\n}\n\n/**\n * Enables support for the hardware back button on Android.\n */\nexport function useHardwareBackButton() {\n React.useEffect(() => {\n function handleHardwardBackPress() {\n return undefined;\n // TODO: The implementation will be something like this\n // if (history.index === 0) {\n // return false; // home screen\n // } else {\n // history.back();\n // return true;\n // }\n }\n\n BackHandler.addEventListener(\n HardwareBackPressEventType,\n handleHardwardBackPress\n );\n\n return () => {\n BackHandler.removeEventListener(\n HardwareBackPressEventType,\n handleHardwardBackPress\n );\n };\n }, []);\n}\n\nexport { useHardwareBackButton as useAndroidBackButton };\n\n/**\n * Enables deep linking, both on the initial app launch and for\n * subsequent incoming links.\n */\nexport function useDeepLinking() {\n let navigate = useNavigate();\n\n // Get the initial URL\n React.useEffect(() => {\n let current = true;\n\n Linking.getInitialURL().then((url) => {\n if (current) {\n if (url) navigate(trimScheme(url));\n }\n });\n\n return () => {\n current = false;\n };\n }, [navigate]);\n\n // Listen for URL changes\n React.useEffect(() => {\n function handleURLChange(event: { url: string }) {\n navigate(trimScheme(event.url));\n }\n\n Linking.addEventListener(URLEventType, handleURLChange);\n\n return () => {\n Linking.removeEventListener(URLEventType, handleURLChange);\n };\n }, [navigate]);\n}\n\nfunction trimScheme(url: string) {\n return url.replace(/^.*?:\\/\\//, \"\");\n}\n\n/**\n * A convenient wrapper for accessing individual query parameters via the\n * URLSearchParams interface.\n */\nexport function useSearchParams(\n defaultInit?: URLSearchParamsInit\n): [URLSearchParams, SetURLSearchParams] {\n let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));\n let hasSetSearchParamsRef = React.useRef(false);\n\n let location = useLocation();\n let searchParams = React.useMemo(() => {\n let searchParams = createSearchParams(location.search);\n\n if (!hasSetSearchParamsRef.current) {\n for (let key of defaultSearchParamsRef.current.keys()) {\n if (!searchParams.has(key)) {\n defaultSearchParamsRef.current.getAll(key).forEach((value) => {\n searchParams.append(key, value);\n });\n }\n }\n }\n\n return searchParams;\n }, [location.search]);\n\n let navigate = useNavigate();\n let setSearchParams = React.useCallback<SetURLSearchParams>(\n (nextInit, navigateOpts) => {\n const newSearchParams = createSearchParams(\n typeof nextInit === \"function\" ? nextInit(searchParams) : nextInit\n );\n hasSetSearchParamsRef.current = true;\n navigate(\"?\" + newSearchParams, navigateOpts);\n },\n [navigate, searchParams]\n );\n\n return [searchParams, setSearchParams];\n}\n\nexport type SetURLSearchParams = (\n nextInit?:\n | URLSearchParamsInit\n | ((prev: URLSearchParams) => URLSearchParamsInit),\n navigateOpts?: NavigateOptions\n) => void;\n\nexport type ParamKeyValuePair = [string, string];\n\nexport type URLSearchParamsInit =\n | string\n | ParamKeyValuePair[]\n | Record<string, string | string[]>\n | URLSearchParams;\n\n/**\n * Creates a URLSearchParams object using the given initializer.\n *\n * This is identical to `new URLSearchParams(init)` except it also\n * supports arrays as values in the object form of the initializer\n * instead of just strings. This is convenient when you need multiple\n * values for a given key, but don't want to use an array initializer.\n *\n * For example, instead of:\n *\n * let searchParams = new URLSearchParams([\n * ['sort', 'name'],\n * ['sort', 'price']\n * ]);\n *\n * you can do:\n *\n * let searchParams = createSearchParams({\n * sort: ['name', 'price']\n * });\n */\nexport function createSearchParams(\n init: URLSearchParamsInit = \"\"\n): URLSearchParams {\n return new URLSearchParams(\n typeof init === \"string\" ||\n Array.isArray(init) ||\n init instanceof URLSearchParams\n ? init\n : Object.keys(init).reduce((memo, key) => {\n let value = init[key];\n return memo.concat(\n Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]\n );\n }, [] as ParamKeyValuePair[])\n );\n}\n"],"names":["NativeRouter","props","React","createElement","MemoryRouter","Object","assign","Link","_ref","onPress","relative","_ref$replace","replace","state","to","rest","_objectWithoutProperties","_excluded","internalOnPress","useLinkPressHandler","handlePress","event","defaultPrevented","TouchableHighlight","HardwareBackPressEventType","URLEventType","_ref2","arguments","length","undefined","navigate","useNavigate","useHardwareBackButton","useEffect","handleHardwardBackPress","BackHandler","addEventListener","removeEventListener","useDeepLinking","current","Linking","getInitialURL","then","url","trimScheme","handleURLChange","useSearchParams","defaultInit","defaultSearchParamsRef","useRef","createSearchParams","hasSetSearchParamsRef","location","useLocation","searchParams","useMemo","search","_loop","key","has","getAll","forEach","value","append","keys","setSearchParams","useCallback","nextInit","navigateOpts","newSearchParams","init","URLSearchParams","Array","isArray","reduce","memo","concat","map","v"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEA6JgBA,YAAYA,CAACC,KAAwB,CAAA,CACnD,OAAOC,KAAC,CAAAC,aAAA,CAAAC,YAAY,CAAAC,MAAA,CAAAC,MAAA,CAAA,EAAA,CAAKL,KAAK,EAAI,CACpC,CAcgB,SAAAM,IAAIA,CAAAC,IAAA,CAOR,CAAA,IANVC,OAAO,CAAAD,IAAA,CAAPC,OAAO,CACPC,QAAQ,CAAAF,IAAA,CAARE,QAAQ,CAAAC,YAAA,CAAAH,IAAA,CACRI,OAAO,CAAPA,OAAO,CAAAD,YAAA,GAAG,KAAA,CAAA,CAAA,KAAK,CAAAA,YAAA,CACfE,KAAK,CAAAL,IAAA,CAALK,KAAK,CACLC,EAAE,CAAAN,IAAA,CAAFM,EAAE,CACCC,IAAI,CAAAC,wBAAA,CAAAR,IAAA,CAAAS,SAAA,CAAA,CAEP,IAAIC,eAAe,CAAGC,mBAAmB,CAACL,EAAE,CAAE,CAAEF,OAAO,CAAPA,OAAO,CAAEC,KAAK,CAALA,KAAK,CAAEH,QAAQ,CAARA,QAAQ,CAAE,CAAC,CAC3E,SAASU,WAAWA,CAACC,KAA4B,CAAA,CAC/C,GAAIZ,OAAO,CAAEA,OAAO,CAACY,KAAK,CAAC,CAC3B,GAAI,CAACA,KAAK,CAACC,gBAAgB,CAAE,CAC3BJ,eAAe,CAACG,KAAK,CAAC,CACvB,CACH,CAEA,OAAOnB,KAAA,CAAAC,aAAA,CAACoB,kBAAkB,CAAAlB,MAAA,CAAAC,MAAA,CAAA,EAAA,CAAKS,IAAI,CAAA,CAAEN,OAAO,CAAEW,WAAW,CAAA,CAAA,CAAI,CAC/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J,KAAK,CAACC,OAAO,CAACX,KAAK,CAAC,CAAGA,KAAK,CAACe,GAAG,CAAC,SAACC,CAAC,CAAA,CAAA,OAAK,CAACpB,GAAG,CAAEoB,CAAC,CAAC,CAAA,CAAA,CAAC,CAAG,CAAC,CAACpB,GAAG,CAAEI,KAAK,CAAC,CAAC,CACnE,CACH,CAAC,CAAE,EAAyB,CAAC,CAClC,CACH;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../index.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type {\n GestureResponderEvent,\n TouchableHighlightProps,\n} from \"react-native\";\nimport { BackHandler, Linking, TouchableHighlight } from \"react-native\";\nimport type {\n To,\n MemoryRouterProps,\n NavigateOptions,\n RelativeRoutingType,\n} from \"react-router\";\nimport { MemoryRouter, useLocation, useNavigate } from \"react-router\";\n\nimport URLSearchParams from \"@ungap/url-search-params\";\n\n////////////////////////////////////////////////////////////////////////////////\n// RE-EXPORTS\n////////////////////////////////////////////////////////////////////////////////\n\n// Note: Keep in sync with react-router exports!\nexport type {\n ActionFunction,\n ActionFunctionArgs,\n AwaitProps,\n Blocker,\n BlockerFunction,\n DataRouteMatch,\n DataRouteObject,\n DataStrategyFunction,\n DataStrategyFunctionArgs,\n DataStrategyMatch,\n DataStrategyResult,\n ErrorResponse,\n Fetcher,\n FutureConfig,\n Hash,\n IndexRouteObject,\n IndexRouteProps,\n JsonFunction,\n LazyRouteFunction,\n LayoutRouteProps,\n LoaderFunction,\n LoaderFunctionArgs,\n Location,\n MemoryRouterProps,\n NavigateFunction,\n NavigateOptions,\n NavigateProps,\n Navigation,\n Navigator,\n NonIndexRouteObject,\n OutletProps,\n Params,\n ParamParseKey,\n Path,\n PathMatch,\n Pathname,\n PathParam,\n PathPattern,\n PathRouteProps,\n RedirectFunction,\n RelativeRoutingType,\n RouteMatch,\n RouteObject,\n RouteProps,\n RouterProps,\n RouterProviderProps,\n RoutesProps,\n Search,\n ShouldRevalidateFunction,\n ShouldRevalidateFunctionArgs,\n To,\n UIMatch,\n} from \"react-router\";\nexport {\n AbortedDeferredError,\n Await,\n MemoryRouter,\n Navigate,\n NavigationType,\n Outlet,\n Route,\n Router,\n RouterProvider,\n Routes,\n createMemoryRouter,\n createPath,\n createRoutesFromChildren,\n createRoutesFromElements,\n defer,\n isRouteErrorResponse,\n generatePath,\n json,\n matchPath,\n matchRoutes,\n parsePath,\n redirect,\n redirectDocument,\n replace,\n renderMatches,\n resolvePath,\n useActionData,\n useAsyncError,\n useAsyncValue,\n useBlocker,\n useHref,\n useInRouterContext,\n useLoaderData,\n useLocation,\n useMatch,\n useMatches,\n useNavigate,\n useNavigation,\n useNavigationType,\n useOutlet,\n useOutletContext,\n useParams,\n useResolvedPath,\n useRevalidator,\n useRouteError,\n useRouteLoaderData,\n useRoutes,\n} from \"react-router\";\n\n///////////////////////////////////////////////////////////////////////////////\n// DANGER! PLEASE READ ME!\n// We provide these exports as an escape hatch in the event that you need any\n// routing data that we don't provide an explicit API for. With that said, we\n// want to cover your use case if we can, so if you feel the need to use these\n// we want to hear from you. Let us know what you're building and we'll do our\n// best to make sure we can support you!\n//\n// We consider these exports an implementation detail and do not guarantee\n// against any breaking changes, regardless of the semver release. Use with\n// extreme caution and only if you understand the consequences. Godspeed.\n///////////////////////////////////////////////////////////////////////////////\n\n/** @internal */\nexport {\n UNSAFE_DataRouterContext,\n UNSAFE_DataRouterStateContext,\n UNSAFE_NavigationContext,\n UNSAFE_LocationContext,\n UNSAFE_RouteContext,\n UNSAFE_useRouteId,\n} from \"react-router\";\n\n////////////////////////////////////////////////////////////////////////////////\n// COMPONENTS\n////////////////////////////////////////////////////////////////////////////////\n\nexport interface NativeRouterProps extends MemoryRouterProps {}\n\n/**\n * A `<Router>` that runs on React Native.\n */\nexport function NativeRouter(props: NativeRouterProps) {\n return <MemoryRouter {...props} />;\n}\n\nexport interface LinkProps extends TouchableHighlightProps {\n children?: React.ReactNode;\n onPress?: (event: GestureResponderEvent) => void;\n relative?: RelativeRoutingType;\n replace?: boolean;\n state?: any;\n to: To;\n}\n\n/**\n * A `<TouchableHighlight>` that navigates to a different URL when touched.\n */\nexport function Link({\n onPress,\n relative,\n replace = false,\n state,\n to,\n ...rest\n}: LinkProps) {\n let internalOnPress = useLinkPressHandler(to, { replace, state, relative });\n function handlePress(event: GestureResponderEvent) {\n if (onPress) onPress(event);\n if (!event.defaultPrevented) {\n internalOnPress(event);\n }\n }\n\n return <TouchableHighlight {...rest} onPress={handlePress} />;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// HOOKS\n////////////////////////////////////////////////////////////////////////////////\n\nconst HardwareBackPressEventType = \"hardwareBackPress\";\nconst URLEventType = \"url\";\n\n/**\n * Handles the press behavior for router `<Link>` components. This is useful if\n * you need to create custom `<Link>` components with the same press behavior we\n * use in our exported `<Link>`.\n */\nexport function useLinkPressHandler(\n to: To,\n {\n replace,\n state,\n relative,\n }: {\n replace?: boolean;\n state?: any;\n relative?: RelativeRoutingType;\n } = {}\n): (event: GestureResponderEvent) => void {\n let navigate = useNavigate();\n return function handlePress() {\n navigate(to, { replace, state, relative });\n };\n}\n\n/**\n * Enables support for the hardware back button on Android.\n */\nexport function useHardwareBackButton() {\n React.useEffect(() => {\n function handleHardwardBackPress() {\n return undefined;\n // TODO: The implementation will be something like this\n // if (history.index === 0) {\n // return false; // home screen\n // } else {\n // history.back();\n // return true;\n // }\n }\n\n BackHandler.addEventListener(\n HardwareBackPressEventType,\n handleHardwardBackPress\n );\n\n return () => {\n BackHandler.removeEventListener(\n HardwareBackPressEventType,\n handleHardwardBackPress\n );\n };\n }, []);\n}\n\nexport { useHardwareBackButton as useAndroidBackButton };\n\n/**\n * Enables deep linking, both on the initial app launch and for\n * subsequent incoming links.\n */\nexport function useDeepLinking() {\n let navigate = useNavigate();\n\n // Get the initial URL\n React.useEffect(() => {\n let current = true;\n\n Linking.getInitialURL().then((url) => {\n if (current) {\n if (url) navigate(trimScheme(url));\n }\n });\n\n return () => {\n current = false;\n };\n }, [navigate]);\n\n // Listen for URL changes\n React.useEffect(() => {\n function handleURLChange(event: { url: string }) {\n navigate(trimScheme(event.url));\n }\n\n Linking.addEventListener(URLEventType, handleURLChange);\n\n return () => {\n Linking.removeEventListener(URLEventType, handleURLChange);\n };\n }, [navigate]);\n}\n\nfunction trimScheme(url: string) {\n return url.replace(/^.*?:\\/\\//, \"\");\n}\n\n/**\n * A convenient wrapper for accessing individual query parameters via the\n * URLSearchParams interface.\n */\nexport function useSearchParams(\n defaultInit?: URLSearchParamsInit\n): [URLSearchParams, SetURLSearchParams] {\n let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));\n let hasSetSearchParamsRef = React.useRef(false);\n\n let location = useLocation();\n let searchParams = React.useMemo(() => {\n let searchParams = createSearchParams(location.search);\n\n if (!hasSetSearchParamsRef.current) {\n for (let key of defaultSearchParamsRef.current.keys()) {\n if (!searchParams.has(key)) {\n defaultSearchParamsRef.current.getAll(key).forEach((value) => {\n searchParams.append(key, value);\n });\n }\n }\n }\n\n return searchParams;\n }, [location.search]);\n\n let navigate = useNavigate();\n let setSearchParams = React.useCallback<SetURLSearchParams>(\n (nextInit, navigateOpts) => {\n const newSearchParams = createSearchParams(\n typeof nextInit === \"function\" ? nextInit(searchParams) : nextInit\n );\n hasSetSearchParamsRef.current = true;\n navigate(\"?\" + newSearchParams, navigateOpts);\n },\n [navigate, searchParams]\n );\n\n return [searchParams, setSearchParams];\n}\n\nexport type SetURLSearchParams = (\n nextInit?:\n | URLSearchParamsInit\n | ((prev: URLSearchParams) => URLSearchParamsInit),\n navigateOpts?: NavigateOptions\n) => void;\n\nexport type ParamKeyValuePair = [string, string];\n\nexport type URLSearchParamsInit =\n | string\n | ParamKeyValuePair[]\n | Record<string, string | string[]>\n | URLSearchParams;\n\n/**\n * Creates a URLSearchParams object using the given initializer.\n *\n * This is identical to `new URLSearchParams(init)` except it also\n * supports arrays as values in the object form of the initializer\n * instead of just strings. This is convenient when you need multiple\n * values for a given key, but don't want to use an array initializer.\n *\n * For example, instead of:\n *\n * let searchParams = new URLSearchParams([\n * ['sort', 'name'],\n * ['sort', 'price']\n * ]);\n *\n * you can do:\n *\n * let searchParams = createSearchParams({\n * sort: ['name', 'price']\n * });\n */\nexport function createSearchParams(\n init: URLSearchParamsInit = \"\"\n): URLSearchParams {\n return new URLSearchParams(\n typeof init === \"string\" ||\n Array.isArray(init) ||\n init instanceof URLSearchParams\n ? init\n : Object.keys(init).reduce((memo, key) => {\n let value = init[key];\n return memo.concat(\n Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]\n );\n }, [] as ParamKeyValuePair[])\n );\n}\n"],"names":["NativeRouter","props","React","createElement","MemoryRouter","Object","assign","Link","_ref","onPress","relative","_ref$replace","replace","state","to","rest","_objectWithoutProperties","_excluded","internalOnPress","useLinkPressHandler","handlePress","event","defaultPrevented","TouchableHighlight","HardwareBackPressEventType","URLEventType","_ref2","arguments","length","undefined","navigate","useNavigate","useHardwareBackButton","useEffect","handleHardwardBackPress","BackHandler","addEventListener","removeEventListener","useDeepLinking","current","Linking","getInitialURL","then","url","trimScheme","handleURLChange","useSearchParams","defaultInit","defaultSearchParamsRef","useRef","createSearchParams","hasSetSearchParamsRef","location","useLocation","searchParams","useMemo","search","_loop","key","has","getAll","forEach","value","append","keys","setSearchParams","useCallback","nextInit","navigateOpts","newSearchParams","init","URLSearchParams","Array","isArray","reduce","memo","concat","map","v"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEA6JgBA,YAAYA,CAACC,KAAwB,CAAA,CACnD,OAAOC,KAAC,CAAAC,aAAA,CAAAC,YAAY,CAAAC,MAAA,CAAAC,MAAA,CAAA,EAAA,CAAKL,KAAK,EAAI,CACpC,CAcgB,SAAAM,IAAIA,CAAAC,IAAA,CAOR,CAAA,IANVC,OAAO,CAAAD,IAAA,CAAPC,OAAO,CACPC,QAAQ,CAAAF,IAAA,CAARE,QAAQ,CAAAC,YAAA,CAAAH,IAAA,CACRI,OA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AAO,CAAG,IAAI,CACpCT,QAAQ,CAAC,GAAG,CAAGuC,eAAe,CAAED,YAAY,CAAC,CAC/C,CAAC,CACD,CAACtC,QAAQ,CAAEwB,YAAY,CAAC,CACzB,CAED,OAAO,CAACA,YAAY,CAAEW,eAAe,CAAC,CACxC,CAsCgB,SAAAf,kBAAkBA,EACF,CAAA,IAA9BoB,IAAA,CAAA3C,SAAA,CAAAC,MAAA,CAAA,CAAA,EAAAD,SAAA,CAAA,CAAA,CAAA,GAAAE,SAAA,CAAAF,SAAA,CAAA,CAAA,CAAA,CAA4B,EAAE,CAE9B,OAAO,IAAI4C,eAAe,CACxB,OAAOD,IAAI,GAAK,QAAQ,EACxBE,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,EACnBA,IAAI,YAAYC,eAAe,CAC3BD,IAAI,CACJjE,MAAM,CAAC2D,IAAI,CAACM,IAAI,CAAC,CAACI,MAAM,CAAC,SAACC,IAAI,CAAEjB,GAAG,CAAI,CACrC,IAAII,KAAK,CAAGQ,IAAI,CAACZ,GAAG,CAAC,CACrB,OAAOiB,IAAI,CAACC,MAAM,CAChBJ,KAAK,CAACC,OAAO,CAACX,KAAK,CAAC,CAAGA,KAAK,CAACe,GAAG,CAAC,SAACC,CAAC,CAAA,CAAA,OAAK,CAACpB,GAAG,CAAEoB,CAAC,CAAC,CAAA,CAAA,CAAC,CAAG,CAAC,CAACpB,GAAG,CAAEI,KAAK,CAAC,CAAC,CACnE,CACH,CAAC,CAAE,EAAyB,CAAC,CAClC,CACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-router-native",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.27.0-pre.0",
|
|
4
4
|
"description": "Declarative routing for React Native applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@ungap/url-search-params": "^0.2.2",
|
|
25
|
-
"react-router": "6.
|
|
25
|
+
"react-router": "6.27.0-pre.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/react-test-renderer": "^18.0.0",
|
|
29
29
|
"react": "^18.2.0",
|
|
30
30
|
"react-native": "^0.69.5",
|
|
31
31
|
"react-test-renderer": "^18.2.0",
|
|
32
|
-
"react-router-native": "6.
|
|
32
|
+
"react-router-native": "6.27.0-pre.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": ">=16.8",
|