UNPKG

@uiw/react-amap-utils

Version:

基于 React 封装的高德地图组件。AMap Component Based On React.

62 lines (61 loc) 2.02 kB
export * from './usePortal'; /** * 对实例有 setStatus 更改状态的处理 * @param instance * @param props * @param propsName */ export declare function useSetStatus<T extends { getStatus: () => any; setStatus: (opt: any) => void; }, F = {}>(instance: T, props?: F, propsName?: string[]): void; /** * 针对 Overlay 类型的组件,有公共的是否显示 对象处理 * 通过参数 `visiable` 来控制执行 `show()` or `hide()` */ export declare function useVisiable<T extends { show: () => void; hide: () => void; }>(instance: T, visible?: boolean): void; /** * 获取上一轮的 props 或 state * How to get the previous props or state? * https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state * @example * ```js * function Counter() { * const [count, setCount] = useState(0); * const prevCount = usePrevious(count); * return <h1>Now: {count}, before: {prevCount}</h1>; * } * ``` */ export declare function usePrevious<T>(value: T): T | undefined; export type EventNameType = 'LowerCase'; /** * 绑定事件 * @param instance 实例对象 * @param props 传递进来的 props * @param eventName 事件的名字,如,我们使用 `onClick` 事件,最终被转换成,`click` 绑定到实例中,`onDblClick` => `dblclick` * * @example * ```js * useEventProperties<BMap.Marker, UseMarker>(marker!, props, [ * 'onMouseMove', 'onZoomChange', 'onMapMove', 'onMouseWheel', 'onZoomStart' * ]); * ``` */ export declare function useEventProperties<T extends AMap.MapEventListener<any>, F>(instance: T, props?: F, eventName?: string[], type?: EventNameType): void; /** * 属性受控 * @param instance 实例对象 * @param props 属性值 * @param propsName 多个属性设置的名称 * @example * ```ts * useSettingProperties<AMap.Polyline, UsePolyline>(polyline!, props, [ * 'Path' * ]); * ``` */ export declare function useSettingProperties<T, F = {}>(instance?: T, props?: F, propsName?: string[]): void;