Skip to content

Commit

Permalink
Canceled subscribe on promise function
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarski committed Oct 26, 2019
1 parent 2db048b commit 7f692bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ const InnerContainer = styled('div')<{ isFontLoaded: boolean }>`
const Layout: React.FunctionComponent<LayoutProps> = ({ 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 (
<Container {...props}>
Expand Down

0 comments on commit 7f692bd

Please sign in to comment.