-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
53 lines (45 loc) · 1.37 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import 'react-native-polyfill-globals/auto';
import '@azure/core-asynciterator-polyfill';
import { usePowerSyncWatchedQuery } from '@journeyapps/powersync-sdk-react-native';
import { PowerSyncProvider } from './library/provider';
import { LIST_TABLE, TODO_TABLE } from './library/AppSchema';
import { ScrollView } from 'react-native';
import React from 'react';
export default function App() {
// The outer layer of this app, the entire purpose of this is to wrap everything in the PowerSyncProvider
return (
<PowerSyncProvider>
<Page/>
</PowerSyncProvider>
);
}
function Page() {
const listRecords = usePowerSyncWatchedQuery<ListRecord>(`
SELECT
api_list.*
FROM
api_list
`);
console.log(listRecords);
return (
<View style={styles.container}>
<ScrollView key={'lists'} style={{ maxHeight: '90%' }}>
{listRecords.map((r) => (
<Text key="{{r.id}}">{r.name} / {r.id}</Text>
))}
</ScrollView>
<Text>You've reached the end of your todos. </Text>
<StatusBar style="auto" />
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});