-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
executable file
·40 lines (36 loc) · 966 Bytes
/
App.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
35
36
37
38
39
40
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* Generated with the TypeScript template
* https://github.com/react-native-community/react-native-template-typescript
*
* @format
*/
import React, {Fragment} from 'react';
import {
StatusBar,
} from 'react-native';
import { useRegistry, useBridge } from 'lepont';
import { WebView } from 'react-native-webview';
const webBundlePrefix = Platform.OS === 'android' ? 'file:///android_asset/' : ''
const App = () => {
const registry = useRegistry()
useBridge(registry, 'foo', async (payload, bridge) => {
setInterval(() => {
bridge.sendMessage({ type: 'bar', payload })
}, 1000)
console.log('foo')
return 43
})
return (
<WebView
javaScriptEnabled
source={{ uri: `${webBundlePrefix}Web.bundle/loader.html` }}
originWhitelist={['*']}
ref={registry.ref}
onMessage={registry.onMessage}
/>
);
};
export default App;