react-query#ReactQueryErrorResetBoundary TypeScript Examples
The following examples show how to use
react-query#ReactQueryErrorResetBoundary.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Routes.tsx From vsinder with Apache License 2.0 | 5 votes |
Routes: React.FC<RoutesProps> = ({}) => {
const { editorBackground } = useTheme();
const { data, isLoading } = useQuery<MeResponse>("/me");
const routeNameRef = React.useRef<string | undefined>();
const navigationRef = React.useRef<NavigationContainerRef>(null);
let body: any = null;
if (isLoading) {
body = <FullscreenLoading />;
} else if (!data?.user) {
body = <AuthStack />;
} else if (data.user.goal && data.user.codeImgIds.length) {
body = <MainTabStack />;
} else {
body = <ProfileStack isNewUser />;
}
return (
<SafeAreaView style={{ flex: 1, backgroundColor: editorBackground }}>
<ReactQueryErrorResetBoundary>
{({ reset }) => (
<ErrorBoundary
onReset={reset}
FallbackComponent={ErrorFallback}
onError={myErrorHandler}
>
<NavigationContainer
ref={navigationRef}
onStateChange={() => {
const previousRouteName = routeNameRef.current;
const currentRouteName = navigationRef.current?.getCurrentRoute()
?.name;
if (previousRouteName !== currentRouteName) {
if (
!["swiper", "viewProfile", "matchy"].includes(
currentRouteName || ""
)
) {
useShowTabs.getState().set({ show: false });
} else {
useShowTabs.getState().set({ show: true });
}
}
routeNameRef.current = currentRouteName;
}}
linking={linking}
fallback={<FullscreenLoading />}
>
{body}
</NavigationContainer>
</ErrorBoundary>
)}
</ReactQueryErrorResetBoundary>
</SafeAreaView>
);
}
Example #2
Source File: Routes.tsx From vsinder-app with Apache License 2.0 | 5 votes |
Routes: React.FC<RoutesProps> = ({}) => {
const { editorBackground } = useTheme();
const { data, isLoading } = useQuery<MeResponse>("/me");
const routeNameRef = React.useRef<string | undefined>();
const navigationRef = React.useRef<NavigationContainerRef>(null);
let body: any = null;
if (isLoading) {
body = <FullscreenLoading />;
} else if (!data?.user) {
body = <AuthStack />;
} else if (data.user.goal && data.user.codeImgIds.length) {
body = <MainTabStack />;
} else {
body = <ProfileStack isNewUser />;
}
return (
<SafeAreaView style={{ flex: 1, backgroundColor: editorBackground }}>
<ReactQueryErrorResetBoundary>
{({ reset }) => (
<ErrorBoundary
onReset={reset}
FallbackComponent={ErrorFallback}
onError={myErrorHandler}
>
<NavigationContainer
ref={navigationRef}
onStateChange={() => {
const previousRouteName = routeNameRef.current;
const currentRouteName = navigationRef.current?.getCurrentRoute()
?.name;
if (previousRouteName !== currentRouteName) {
if (
!["swiper", "viewProfile", "matchy"].includes(
currentRouteName || ""
)
) {
useShowTabs.getState().set({ show: false });
} else {
useShowTabs.getState().set({ show: true });
}
}
routeNameRef.current = currentRouteName;
}}
linking={linking}
fallback={<FullscreenLoading />}
>
{body}
</NavigationContainer>
</ErrorBoundary>
)}
</ReactQueryErrorResetBoundary>
</SafeAreaView>
);
}