Skip to content

Commit

Permalink
build: install @tanstack/react-query, react-native-encrypted-storage
Browse files Browse the repository at this point in the history
  • Loading branch information
timepresent95 committed Aug 2, 2024
1 parent 7366e4b commit 776acd0
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 5 deletions.
11 changes: 8 additions & 3 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import {QueryClientProvider} from '@tanstack/react-query';
import React from 'react';
import {SafeAreaView, Text} from 'react-native';

import queryClient from '@/api/queryClient';

function App() {
return (
<SafeAreaView>
<Text className="text-orange-300">Hellow World</Text>
</SafeAreaView>
<QueryClientProvider client={queryClient}>
<SafeAreaView>
<Text className="text-orange-300">Hellow World</Text>
</SafeAreaView>
</QueryClientProvider>
);
}

Expand Down
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,8 @@ PODS:
- react-native-config/App (= 1.5.2)
- react-native-config/App (1.5.2):
- React-Core
- react-native-encrypted-storage (4.0.3):
- React-Core
- React-nativeconfig (0.74.3)
- React-NativeModulesApple (0.74.3):
- glog
Expand Down Expand Up @@ -1205,6 +1207,7 @@ DEPENDENCIES:
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
- react-native-config (from `../node_modules/react-native-config`)
- react-native-encrypted-storage (from `../node_modules/react-native-encrypted-storage`)
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
Expand Down Expand Up @@ -1298,6 +1301,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
react-native-config:
:path: "../node_modules/react-native-config"
react-native-encrypted-storage:
:path: "../node_modules/react-native-encrypted-storage"
React-nativeconfig:
:path: "../node_modules/react-native/ReactCommon"
React-NativeModulesApple:
Expand Down Expand Up @@ -1379,6 +1384,7 @@ SPEC CHECKSUMS:
React-logger: fa92ba4d3a5d39ac450f59be2a3cec7b099f0304
React-Mapbuffer: 9f68550e7c6839d01411ac8896aea5c868eff63a
react-native-config: d7d8a0c65f7fa523197879f6b777997abbfc987e
react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7
React-nativeconfig: fa5de9d8f4dbd5917358f8ad3ad1e08762f01dcb
React-NativeModulesApple: 585d1b78e0597de364d259cb56007052d0bda5e5
React-perflogger: 7bb9ba49435ff66b666e7966ee10082508a203e8
Expand Down
37 changes: 36 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
"test": "jest"
},
"dependencies": {
"@tanstack/react-query": "^5.51.18",
"nativewind": "^2.0.11",
"react": "18.2.0",
"react-native": "0.74.3",
"react-native-config": "^1.5.2"
"react-native-config": "^1.5.2",
"react-native-encrypted-storage": "^4.0.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
14 changes: 14 additions & 0 deletions src/api/queryClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {QueryClient} from '@tanstack/react-query';

const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: false,
},
mutations: {
retry: false,
},
},
});

export default queryClient;
20 changes: 20 additions & 0 deletions src/utils/encryptStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import EncryptedStorage from 'react-native-encrypted-storage';

const setEncryptStorage = async <T>(key: string, data: T) => {
await EncryptedStorage.setItem(key, JSON.stringify(data));
};

const getEncryptStorage = async (key: string) => {
const storedData = await EncryptedStorage.getItem(key);

return storedData ? JSON.parse(storedData) : null;
};

const removeEncryptStorage = async (key: string) => {
const data = await getEncryptStorage(key);
if (data) {
await EncryptedStorage.removeItem(key);
}
};

export {setEncryptStorage, getEncryptStorage, removeEncryptStorage};

0 comments on commit 776acd0

Please sign in to comment.