-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
54 lines (50 loc) · 1.27 KB
/
App.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import {
NativeModules,
View,
requireNativeComponent,
NativeEventEmitter,
LogBox,
Platform,
} from 'react-native';
import React, {useEffect} from 'react';
import Toast from 'react-native-simple-toast';
LogBox.ignoreLogs([
'Module RNEventEmitter requires main queue setup since it overrides ',
'new NativeEventEmitter()',
]);
const QRModule = requireNativeComponent(
Platform.OS == 'android' ? 'QRModuleAndroid' : 'QRModuleIOS',
);
const eventEmitter = new NativeEventEmitter(NativeModules.RNEventEmitter);
export default function App() {
useEffect(() => {
console.log('in use effect');
eventEmitter.addListener('onCodeSuccess', res =>
Toast.show(res, Toast.LONG),
);
return () => eventEmitter.removeAllListeners('onCodeSuccess');
});
return (
<View
style={{
justifyContent: 'center',
alignItems: 'center',
height: '100%',
backgroundColor: 'tomato',
}}>
<View
style={{
margin: 50,
overflow: 'hidden',
position: 'absolute',
width: '80%',
height: '40%',
backgroundColor: 'purple',
}}>
<QRModule
style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}
/>
</View>
</View>
);
}