-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppProvider.tsx
52 lines (48 loc) · 1.14 KB
/
AppProvider.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
import {
MutationCache,
QueryCache,
QueryClient,
QueryClientProvider,
} from '@tanstack/react-query';
import { Alert } from 'react-native';
import App from './App';
import { AxiosError } from 'axios';
import React from 'react';
import { RecoilRoot } from 'recoil';
const AppProvider = () => {
// * react query 글로벌 에러 핸들링 세팅
const queryClient = new QueryClient({
queryCache: new QueryCache({
onError: error => {
const axiosError = error as AxiosError<string>;
if (__DEV__) {
Alert.alert('오류', axiosError.message, [
{
text: '확인',
},
]);
}
},
}),
mutationCache: new MutationCache({
onError: error => {
const axiosError = error as AxiosError<string>;
if (__DEV__) {
Alert.alert('오류', axiosError.message, [
{
text: '확인',
},
]);
}
},
}),
});
return (
<QueryClientProvider client={queryClient}>
<RecoilRoot>
<App />
</RecoilRoot>
</QueryClientProvider>
);
};
export default AppProvider;