From 7c124c1390ea1b8efa071b96f2ee44059946a193 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Sat, 22 Jan 2022 18:32:50 -0600 Subject: [PATCH] home: handle undefined props --- web/pages/home.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/pages/home.tsx b/web/pages/home.tsx index f429cb29..e7fb31cf 100644 --- a/web/pages/home.tsx +++ b/web/pages/home.tsx @@ -71,11 +71,15 @@ const Home = (props: { const user = useUser() - const contracts = useContracts() ?? props.activeContracts + const initialActiveContracts = props.activeContracts ?? [] + + const contracts = useContracts() const recentComments = useRecentComments() - const activeContracts = recentComments - ? findActiveContracts(contracts, recentComments) - : props.activeContracts + + const activeContracts = + recentComments && contracts + ? findActiveContracts(contracts, recentComments) + : initialActiveContracts if (user === null) { Router.replace('/')