-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.js
More file actions
83 lines (73 loc) · 2.14 KB
/
App.js
File metadata and controls
83 lines (73 loc) · 2.14 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import 'react-native-gesture-handler';
import React, {useState, useMemo, useEffect} from 'react';
import AsyncStorage from '@react-native-community/async-storage';
import SplashScreen from 'react-native-splash-screen';
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import {NoteContext} from './src/hooks/NoteContext';
import Home from './src/screens/Home';
import Notes from './src/screens/Notes';
import CheckList from './src/screens/CheckList';
const Stack = createStackNavigator();
const App = () => {
const [data, setData] = useState([]);
const [listData, setListData] = useState([]);
const providerValue = useMemo(
() => ({
data,
setData,
listData,
setListData,
}),
[data, setData, listData, setListData],
);
useEffect(() => {
SplashScreen.hide();
}, []);
useEffect(() => {
const getData = async () => {
try {
const jsonValue = await AsyncStorage.getItem('tasks');
return jsonValue != null ? setData(JSON.parse(jsonValue)) : null;
} catch (e) {
console.log('couldnot retrieve');
// error reading value
}
};
const getCheckData = async () => {
try {
const jsonValue = await AsyncStorage.getItem('checks');
return jsonValue != null ? setListData(JSON.parse(jsonValue)) : null;
} catch (e) {
console.log('couldnot retrieve');
// error reading value
}
};
getCheckData();
getData();
}, []);
return (
<NoteContext.Provider value={providerValue}>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={Home}
options={{headerShown: false}}
/>
<Stack.Screen
name="Notes"
component={Notes}
options={{headerShown: false}}
/>
<Stack.Screen
name="CheckList"
component={CheckList}
options={{headerShown: false}}
/>
</Stack.Navigator>
</NavigationContainer>
</NoteContext.Provider>
);
};
export default App;