forked from wundergraph/wundergraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
55 lines (52 loc) · 1.12 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
54
55
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { useQuery } from './lib/wundergraph';
export default function App() {
const { data, isLoading, error } = useQuery({
operationName: 'Dragons',
});
return (
<View style={styles.container}>
{isLoading && <Text>Loading...</Text>}
{data && (
<View>
{data.spacex_dragons?.map((dragon) => (
<View style={styles.dragon} key={dragon.name}>
<View style={dragon?.active ? styles.active : styles.inactive} />
<Text key={dragon.name}>{dragon.name} </Text>
</View>
))}
</View>
)}
{error && <Text>Something went wrong</Text>}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
color: '#000',
alignItems: 'center',
justifyContent: 'center',
},
dragon: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: 2,
},
active: {
borderRadius: 10,
width: 10,
height: 10,
backgroundColor: 'green',
marginRight: 4,
},
inactive: {
borderRadius: 10,
width: 10,
height: 10,
backgroundColor: 'gray',
marginRight: 4,
},
});