UNPKG

@uiw/react-baidu-map-utils

Version:

Baidu Map utils Components for React.

82 lines (81 loc) 2.78 kB
import React from 'react'; /** * 批量创建多个如下 State,监听并设置值, * 组件属性更改 <Componet enableDragging={true} > * 根据 enableDragging 的 Boolean 值,执行 `enable` 和 `disable` 开头的函数。 * @example * ```js * const [enableDragging, setEnableDragging] = useState(props.enableDragging); * useEffect(() => { * console.log('~~:enableDragging', enableDragging, props.enableDragging, polyline); * setEnableDragging(props.enableDragging) * }, [polyline, enableDragging, props.enableDragging]); * ``` * @param instance * @param props * @param propsName */ export declare function useEnableProperties<T = {}, F = {}>(instance: T, props?: F, propsName?: string[]): void; /** * 针对 Overlay 类型的组件,有公共的是否显示 对象处理 * 通过参数 `visiable` 来控制执行 `show()` or `hide()` */ export declare function useVisiable<T extends BMap.Overlay, F extends { visiable?: boolean; }>(instance: T, props?: F): void; /** * 批量创建多个如下 State,监听并设置值, * 执行 `set` 开头的函数。 * @param instance * @param props * @param propsName */ export declare function useProperties<T, F>(instance: T, props: F, propsName?: string[]): void; export interface EventListener { /** * 添加事件监听函数 * @param event * @param handler */ addEventListener(event: string, handler: any): void; /** * 移除事件监听函数 * @param event * @param handler */ removeEventListener(event: string, handler: any): void; } export type EventNameType = 'CamelCase' | 'PascalCase' | 'LowerCase'; /** * 绑定事件 * @param instance 实例对象 * @param props 传递进来的 props * @param eventName 事件的名字,如,我们使用 `onClick` 事件,最终被转换成,`click` 绑定到实例中,`onDblClick` => `dblclick` * * @example * ```js * useEventProperties<BMap.Marker, UseMarker>(marker!, props, [ * 'Click', 'DblClick', 'MouseDown', 'MouseUp', 'MouseOut', 'MouseOver' * ]); * ``` */ export declare function useEventProperties<T extends EventListener, F>(instance: T, props?: F, eventName?: string[], type?: EventNameType): 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 declare function useRenderDom(props: { children: React.ReactNode; }): { container: HTMLDivElement; };