UNPKG

react-amap-v2

Version:

高德地图 v2.0 react 组件

21 lines (17 loc) 457 B
import { useContext } from 'react'; import { createContainer } from 'unstated-next'; import { Context, MapContext } from '../context'; interface UseMapState { map?: AMap.Map; context?: MapContext; } interface InitialValue { map?: AMap.Map; } export const { Provider, useContainer: useMap } = createContainer< InitialValue, UseMapState >(initialValue => { const context = useContext(Context); return { map: initialValue?.map, context }; });