-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLiveLikeAndroidView.jsx
More file actions
33 lines (29 loc) · 937 Bytes
/
LiveLikeAndroidView.jsx
File metadata and controls
33 lines (29 loc) · 937 Bytes
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
import React, { useEffect, useRef } from 'react';
import { UIManager, findNodeHandle } from 'react-native';
import { PixelRatio} from "react-native";
import { LiveLikeAndroidViewManager } from './android-view-manager';
const createFragment = (viewId) =>
UIManager.dispatchViewManagerCommand(
viewId,
// we are calling the 'create' command
UIManager.LiveLikeAndroidViewManager.Commands.create.toString(),
[viewId]
);
export const LiveLikeAndroidView = () => {
const ref = useRef(null);
useEffect(() => {
const viewId = findNodeHandle(ref.current);
createFragment(viewId);
}, []);
return (
<LiveLikeAndroidViewManager
style={{
// converts dpi to px, provide desired height
height: PixelRatio.getPixelSizeForLayoutSize(750),
// converts dpi to px, provide desired width
width: PixelRatio.getPixelSizeForLayoutSize(400)
}}
ref={ref}
/>
);
};