-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
58 lines (53 loc) · 1.51 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
56
57
58
/**
* 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, { useEffect, useRef } from 'react';
import { Alert, Button, SafeAreaView, ScrollView } from 'react-native';
import {
useProductsCatalogLazyQuery,
useProductsCatalogLazyQueryRaw,
} from './src/request';
import { useApolloClient } from '@apollo/client';
const App = () => {
const client = useApolloClient();
const [query, { data, loading }] = useProductsCatalogLazyQuery({
fetchPolicy: 'network-only',
});
const [rawQuery, { data: dataRaw, loading: loadingRaw }] =
useProductsCatalogLazyQueryRaw(client);
const startRef = useRef<Date>();
useEffect(() => {
if (loading || loadingRaw) {
startRef.current = new Date();
return;
}
if (data || dataRaw) {
Alert.alert(
`Started: ${startRef.current?.toISOString()} Ended: ${new Date().toISOString()}`,
);
}
}, [loading, loadingRaw, data, dataRaw]);
return (
<SafeAreaView>
<ScrollView contentInsetAdjustmentBehavior="automatic">
<Button
title="Request With Apollo"
disabled={loading || loadingRaw}
onPress={() => query()}
/>
<Button
title="Request Without Apollo"
disabled={loading || loadingRaw}
onPress={() => rawQuery()}
/>
</ScrollView>
</SafeAreaView>
);
};
export default App;