tsq-query-boundary
shuip/tsq-query-boundaryFreeComponent
shuip publishes no description for this item.
Install it
npx shadcn@latest add https://shuip.plvo.dev/r/tsq-query-boundary.jsonSource
1'use client';23import { QueryErrorResetBoundary } from '@tanstack/react-query';4import { AlertTriangle, RefreshCcw } from 'lucide-react';5import * as React from 'react';6import { ErrorBoundary, type FallbackProps } from 'react-error-boundary';7import { Button } from '@/components/ui/button';89interface QueryBoundaryProps {10 children: React.ReactNode;11 queryKeys?: string[];12 loadingFallback?: React.ReactNode;13 errorFallback?: (props: FallbackProps) => React.ReactNode;14}1516export function QueryBoundary({17 children,18 queryKeys = [],19 loadingFallback = 'Loading...',20 errorFallback,21}: QueryBoundaryProps) {22 return (23 <QueryErrorResetBoundary>24 {({ reset }) => (25 <ErrorBoundary26 onReset={reset}27 fallbackRender={(props) =>28 errorFallback ? errorFallback(props) : <DefaultErrorFallback {...props} queryKeys={queryKeys} />29 }30 >31 <React.Suspense fallback={loadingFallback}>{children}</React.Suspense>32 </ErrorBoundary>33 )}34 </QueryErrorResetBoundary>35 );36}3738export function DefaultErrorFallback({39 error,40 resetErrorBoundary,41 queryKeys = [],42}: FallbackProps & { queryKeys?: string[] }) {43 return (44 <div className='p-6 rounded-lg border border-destructive/30 bg-destructive/5 flex flex-col items-center justify-center space-y-4 text-center'>45 <AlertTriangle className='text-destructive size-12' />46 <div>47 <h3 className='text-lg font-semibold mb-2'>Oops, something went wrong!</h3>48 <p className='text-muted-foreground'>{error instanceof Error ? error.message : 'Unexpected error'}</p>49 {queryKeys.length && (50 <p className='text-xs text-muted-foreground mt-2'>51 Concerned quer{queryKeys.length > 1 ? 'ies' : 'y'}: {queryKeys.join(', ')}52 </p>53 )}54 </div>55 <Button onClick={resetErrorBoundary} variant='outline' className='gap-2'>56 <RefreshCcw className='size-4' />57 Retry58 </Button>59 </div>60 );61}
What it pulls in
npm packages
Other registry items
Files it writes
More from shuip
All 52 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| confirmation-dialogconfirmation-dialog | shuip | Components | Free | 1 dep | |
| copy-buttoncopy-button | shuip | Components | Free | 3 deps | |
| hover-revealhover-reveal | shuip | Components | Free | 1 dep | |
| rhf-address-fieldrhf-address-field | shuip | Components | Free | 5 deps · 2 files | |
| rhf-autocomplete-fieldrhf-autocomplete-field | shuip | Components | Free | 4 deps | |
| rhf-checkbox-fieldrhf-checkbox-field | shuip | Components | Free | 3 deps | |
| rhf-combobox-fieldrhf-combobox-field | shuip | Components | Free | 5 deps | |
| rhf-date-fieldrhf-date-field | shuip | Components | Free | 6 deps |
