diff --git a/webapp/src/components/boardTemplateSelector/boardTemplateSelectorPreview.tsx b/webapp/src/components/boardTemplateSelector/boardTemplateSelectorPreview.tsx index 30b6a6a03..b0998a3d6 100644 --- a/webapp/src/components/boardTemplateSelector/boardTemplateSelectorPreview.tsx +++ b/webapp/src/components/boardTemplateSelector/boardTemplateSelectorPreview.tsx @@ -27,21 +27,27 @@ const BoardTemplateSelectorPreview = (props: Props) => { const [activeTemplateCards, setActiveTemplateCards] = useState([]) useEffect(() => { + let isSubscribed = true if (activeTemplate) { setActiveTemplateCards([]) setActiveView(null) setActiveTemplateCards([]) octoClient.getAllBlocks(activeTemplate.id).then((blocks) => { - const cards = blocks.filter((b) => b.type === 'card') - const views = blocks.filter((b) => b.type === 'view').sort((a, b) => a.title.localeCompare(b.title)) - if (views.length > 0) { - setActiveView(views[0] as BoardView) - } - if (cards.length > 0) { - setActiveTemplateCards(cards as Card[]) + if (isSubscribed) { + const cards = blocks.filter((b) => b.type === 'card') + const views = blocks.filter((b) => b.type === 'view').sort((a, b) => a.title.localeCompare(b.title)) + if (views.length > 0) { + setActiveView(views[0] as BoardView) + } + if (cards.length > 0) { + setActiveTemplateCards(cards as Card[]) + } } }) } + return () => { + isSubscribed = false + } }, [activeTemplate]) const dateDisplayProperty = useMemo(() => {