-
Notifications
You must be signed in to change notification settings - Fork 1
/
MapView.tsx
34 lines (27 loc) · 902 Bytes
/
MapView.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import * as React from 'react'
import { useEffect, useRef } from 'react';
import { Platform, UIManager, findNodeHandle, requireNativeComponent } from "react-native";
const createFragment = (viewId: number | null) => {
let command = (UIManager as any).MapsIndoorsView.Commands.create;
if (Platform.OS === 'android') {
command = command.toString();
}
UIManager.dispatchViewManagerCommand(
viewId,
// we are calling the 'create' command
command,
[viewId],
);
}
const MapView = ({ style }: { style: any }) => {
const ref = useRef(null);
useEffect(() => {
const viewId = findNodeHandle(ref.current);
createFragment(viewId);
}, []);
return (<MapsIndoorsViewManager
style={style}
ref={ref} />);
}
const MapsIndoorsViewManager = requireNativeComponent('MapsIndoorsView');
export default MapView;