From 4db8aa364144957e1789c4e450445271d558c706 Mon Sep 17 00:00:00 2001 From: Timothy Miller <46549361+timothymiller@users.noreply.github.com> Date: Mon, 18 Sep 2023 02:11:19 -0400 Subject: [PATCH] Better organize tRPC states --- .../app/features/virtualized-list/screen.tsx | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/packages/app/features/virtualized-list/screen.tsx b/packages/app/features/virtualized-list/screen.tsx index 8cf512f24..e651d946b 100644 --- a/packages/app/features/virtualized-list/screen.tsx +++ b/packages/app/features/virtualized-list/screen.tsx @@ -8,32 +8,27 @@ import { SolitoImage } from 'solito/image' export const VirtualizedListScreen = (): React.ReactNode => { const query = trpc.car.all.useQuery() - if (query.isInitialLoading) { - return ( - - Loading... - - - ) - } - return ( - - {query.data?.length ? ( + + {query.isInitialLoading ? ( + // Loading + + Loading... + + + ) : query.data?.length ? ( + // Has Data + ) : query.error ? ( + // Error + + Error fetching cars: {query.error.message} + ) : ( - <> - {query.error ? ( - - Error fetching cars: {query.error.message} - - ) : null} - {!query.isLoading && ( - - No cars found. - - )} - + // Empty State + + No cars found. + )} )