From 7f692bdc6e7cf77b45226e25a20cbc1e74b06f46 Mon Sep 17 00:00:00 2001 From: Daniel Karski Date: Sat, 26 Oct 2019 10:27:58 +0200 Subject: [PATCH] Canceled subscribe on promise function --- components/Layout.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/Layout.tsx b/components/Layout.tsx index 416d93c..cc67fc5 100644 --- a/components/Layout.tsx +++ b/components/Layout.tsx @@ -22,8 +22,10 @@ const InnerContainer = styled('div')<{ isFontLoaded: boolean }>` const Layout: React.FunctionComponent = ({ children, title, ...props }) => { const [isFontLoaded, setIsFontLoaded] = useState(false); useEffect(() => { - Fonts().then(() => setIsFontLoaded(true)); - }); + let isSubscribed = true + Fonts().then(() => isSubscribed ? setIsFontLoaded(true) : null); + return () => {(isSubscribed = false)}; + }, []); return (