UNPKG

@ant-design/react-native

Version:

基于蚂蚁金服移动设计规范的 React Native 组件库

74 lines (73 loc) 2.25 kB
import React from 'react'; import { EventSubscription, GestureResponderEvent, ScrollViewProps } from 'react-native'; import PortalManager from './portal-manager'; export type PortalHostProps = ScrollViewProps; export type Operation = { type: 'mount'; key: number; children: React.ReactNode; } | { type: 'update'; key: number; children: React.ReactNode; } | { type: 'unmount'; key: number; }; export type PortalMethods = { mount: (children: React.ReactNode) => number; update: (key: number, children: React.ReactNode) => void; unmount: (key: number) => void; }; export declare const PortalContext: React.Context<PortalMethods>; declare class PortalGuard { private nextKey; add: (e: React.ReactNode) => number; remove: (key: number) => void; } /** * portal */ export declare const portal: PortalGuard; /** * Portal host renders all of its children `Portal` elements. * For example, you can wrap a screen in `Portal.Host` to render items above the screen. * If you're using the `Provider` component, it already includes `Portal.Host`. * * ## Usage * ```js * import * as React from 'react'; * import { Text } from 'react-native'; * import { Portal } from '@ant-design/react-native'; * * export default class MyComponent extends React.Component { * render() { * return ( * <Portal.Host> * <Text>Content of the app</Text> * </Portal.Host> * ); * } * } * ``` * * Here any `Portal` elements under `<App />` are rendered alongside `<App />` and will appear above `<App />` like a `Modal`. */ export default class PortalHost extends React.Component<PortalHostProps> { static displayName: string; _nextKey: number; _queue: Operation[]; _manager?: PortalManager; _addType: EventSubscription; _removeType: EventSubscription; componentDidMount(): void; componentWillUnmount(): void; _setManager: (manager?: any) => void; _mount: (children: React.ReactNode, _key?: number) => number; _update: (key: number, children: React.ReactNode) => void; _unmount: (key: number) => void; _onTouchMove: () => void; _onTouchEnd: (event: GestureResponderEvent) => void; render(): React.JSX.Element; } export {};