-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFeed.tsx
65 lines (56 loc) · 1.32 KB
/
Feed.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 React, {useEffect, useState} from 'react'
import { StyleSheet, Text, View, RefreshControl } from 'react-native'
import SeniorTicket from './SeniorTicket'
import { useQuery, gql } from '@apollo/client';
import { ScrollView } from 'react-native-gesture-handler';
const GET_TEST = gql`
query {
tasks {
id
type
description
deadline
completed
}
}`
const Feed = () => {
// useEffect(() => {
// console.log('useeffect')
// }, [])
const [refreshing, useRefresh] = useState('false');
const onRefresh = () => {
console.log('refreshing');
}
//wrapper for useQuery
const { loading, error, data } = useQuery(GET_TEST);
if (loading) return <Text>Loading...</Text>;
if (error) {
console.log('error', error)
return <Text>Error :( </Text>;
}
let tickets;
try {
tickets = data.tasks.map( task => <SeniorTicket key={task.id} task={task}/>).reverse();
} catch (e) {
console.log('error in gql feed', e);
}
// console.log('tickets', tickets)
return (
<ScrollView
contentContainerStyle={styles.container}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={onRefresh}
/>}
>
{tickets}
</ScrollView>
)
}
export default Feed
const styles = StyleSheet.create({
container: {
width: '100%',
}
})