mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-12 22:51:18 +08:00
docs: improve jsdoc for linking
This commit is contained in:
@@ -35,7 +35,7 @@ const getActiveRoute = (state: State): { name: string; params?: object } => {
|
||||
/**
|
||||
* Utility to serialize a navigation state object to a path string.
|
||||
*
|
||||
* Example:
|
||||
* @example
|
||||
* ```js
|
||||
* getPathFromState(
|
||||
* {
|
||||
|
||||
@@ -37,7 +37,7 @@ type ResultState = PartialState<NavigationState> & {
|
||||
* Utility to parse a path string to initial state object accepted by the container.
|
||||
* This is useful for deep linking when we need to handle the incoming URL.
|
||||
*
|
||||
* Example:
|
||||
* @example
|
||||
* ```js
|
||||
* getStateFromPath(
|
||||
* '/chat/jane/42',
|
||||
|
||||
@@ -29,16 +29,21 @@ export type LinkingOptions = {
|
||||
* Only applicable on Android and iOS.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* {
|
||||
* prefixes: [
|
||||
* "https://example.com", // Exact
|
||||
* "https://*.example.com" // Match with any subdomain
|
||||
* "myapp://", // App-specific scheme
|
||||
* "https://example.com", // Prefix for universal links
|
||||
* "https://*.example.com" // Prefix which matches any subdomain
|
||||
* ]
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
prefixes: string[];
|
||||
/**
|
||||
* Config to fine-tune how to parse the path.
|
||||
*
|
||||
* Example:
|
||||
* @example
|
||||
* ```js
|
||||
* {
|
||||
* Chat: {
|
||||
@@ -52,13 +57,33 @@ export type LinkingOptions = {
|
||||
/**
|
||||
* Custom function to get the initial URL used for linking.
|
||||
* Uses `Linking.getInitialURL()` by default.
|
||||
* Not supported on the web.
|
||||
* Not supported on Web.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* {
|
||||
* getInitialURL () => Linking.getInitialURL(),
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
getInitialURL?: () => Promise<string | null | undefined>;
|
||||
/**
|
||||
* Custom function to get subscribe to URL updates.
|
||||
* Uses `Linking.addEventListener('url', callback)` by default.
|
||||
* Not supported on the web.
|
||||
* Not supported on Web.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* {
|
||||
* subscribe: (listener) => {
|
||||
* const onReceiveURL = ({ url }) => listener(url);
|
||||
*
|
||||
* Linking.addEventListener('url', onReceiveURL);
|
||||
*
|
||||
* return () => Linking.removeEventListener('url', onReceiveURL);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
subscribe?: (
|
||||
listener: (url: string) => void
|
||||
|
||||
Reference in New Issue
Block a user