-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.jsx
63 lines (51 loc) · 1.52 KB
/
App.jsx
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
import React, { useEffect } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Home from './src/screens/home';
import Paywall from './src/screens/paywall';
import RecipeDetail from './src/screens/recipeDetail';
import {
initConnection,
endConnection,
flushFailedPurchasesCachedAsPendingAndroid,
} from 'react-native-iap';
import { Platform } from 'react-native';
const Stack = createNativeStackNavigator();
const App = () => {
useEffect(() => {
const init = async () => {
try {
await initConnection();
if (Platform.OS === 'android') {
flushFailedPurchasesCachedAsPendingAndroid();
}
}
catch (error) {
console.error('Error occurred during initilization', error.message);
}
}
init();
return () => {
endConnection();
}
}, [])
return (
<NavigationContainer>
<Stack.Navigator
initialRouteName='Home'
screenOptions={{
headerStyle: {
backgroundColor: 'coral'
},
headerTitleAlign: 'center',
headerTintColor: '#fff'
}}
>
<Stack.Screen name='Home' component={Home} options={{ title: 'Recipes' }} />
<Stack.Screen name='Recipe-detail' component={RecipeDetail} />
<Stack.Screen name='Paywall' component={Paywall} options={{ title: 'Upgrade' }} />
</Stack.Navigator>
</NavigationContainer>
);
}
export default App;