From cdce5dfad1e4f165752b08f1183322a210df2716 Mon Sep 17 00:00:00 2001 From: Andrea Simone Porceddu Date: Mon, 1 Nov 2021 10:32:14 +0100 Subject: [PATCH] fix: crash by navigating to a font slice if the fonts slice has no font --- devtool/src/_shared/components/Slices/Fonts/Detail/index.tsx | 2 +- devtool/src/_shared/components/Slices/Fonts/General.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/devtool/src/_shared/components/Slices/Fonts/Detail/index.tsx b/devtool/src/_shared/components/Slices/Fonts/Detail/index.tsx index 6c3e730e..faa42afb 100644 --- a/devtool/src/_shared/components/Slices/Fonts/Detail/index.tsx +++ b/devtool/src/_shared/components/Slices/Fonts/Detail/index.tsx @@ -48,7 +48,7 @@ export const Detail: React.FC = ({ main = 'fonts' }) => { const themeFonts = useThemeSlice('fonts') const firstFont = useMemo(() => { - const fontArray = Object.keys(themeFonts) + const fontArray = Object.keys(themeFonts || {}) return fontArray[0] as Font }, [themeFonts]) diff --git a/devtool/src/_shared/components/Slices/Fonts/General.tsx b/devtool/src/_shared/components/Slices/Fonts/General.tsx index 7902407a..c7350dd9 100644 --- a/devtool/src/_shared/components/Slices/Fonts/General.tsx +++ b/devtool/src/_shared/components/Slices/Fonts/General.tsx @@ -23,7 +23,7 @@ const ItemCard: React.FC = ({ property, value }) => { const themeFonts = useTheme().fonts; const firstFont = useMemo(() => { - const fontArray = Object.keys(themeFonts) + const fontArray = Object.keys(themeFonts || {}) return fontArray[0] as keyof Fonts }, [themeFonts])