From 57c8f6915c17ec54a4193e672756df0f5778bf8f Mon Sep 17 00:00:00 2001 From: Nico Date: Fri, 2 Aug 2024 10:14:35 +0200 Subject: [PATCH] fix(betterActivities): avoid conditional hook calls Prevents crashing when the activities length changes --- src/plugins/betterActivities/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/betterActivities/index.tsx b/src/plugins/betterActivities/index.tsx index bb6ed17c4..73f3e816e 100644 --- a/src/plugins/betterActivities/index.tsx +++ b/src/plugins/betterActivities/index.tsx @@ -154,8 +154,6 @@ export default definePlugin({ setCurrentActivity(activities[0]); }, [activities]); - if (!activities.length) return null; - // we use these for other activities, it would be better to somehow get the corresponding activity props const generalProps = useMemo(() => Object.keys(props).reduce((acc, key) => { // exclude activity specific props to prevent copying them to all activities (e.g. buttons) @@ -163,6 +161,9 @@ export default definePlugin({ return acc; }, {} as Omit), [props]); + + if (!activities.length) return null; + if (settings.store.allActivitiesStyle === "carousel") { return (