-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRouter.tsx
64 lines (61 loc) · 1.41 KB
/
Router.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
54
55
56
57
58
59
60
61
62
63
64
import {
ActivityIndicator,
ScrollView,
StyleSheet,
Text,
View,
} from 'react-native';
import React from 'react';
import {useQuery} from '@apollo/client';
import {GET_ALL_POSTS} from './graphql/allPosts';
const Router = () => {
const {data, loading, error} = useQuery(GET_ALL_POSTS);
console.log('data', data);
console.log('error', error);
return (
<View
style={{
flex: 1,
}}>
{loading ? (
<>
<ActivityIndicator size={'large'} />
</>
) : (
<ScrollView>
<View
style={{
padding: 5,
}}>
<Text
style={{
textAlign: 'center',
fontSize: 25,
fontWeight: 'bold',
}}>
{data?.posts?.data?.length} Data
</Text>
{data?.posts?.data?.map((item: any) => (
<View
style={{
padding: 4,
}}
key={item?.id}>
<Text
style={{
fontWeight: 'bold',
color: '#000',
}}>
{item?.title}
</Text>
<Text>{item?.body}</Text>
</View>
))}
</View>
</ScrollView>
)}
</View>
);
};
export default Router;
const styles = StyleSheet.create({});