From 43b9902d2cdfde60308990a65249467ece3dca91 Mon Sep 17 00:00:00 2001 From: chrfalch Date: Tue, 14 Jun 2022 14:03:40 +0200 Subject: [PATCH 1/2] Removed unused code path from useFont After landing #585 we ended up with an invalid code path. This commit fixes this by returning null instead of a default font. --- package/src/skia/core/Font.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/src/skia/core/Font.ts b/package/src/skia/core/Font.ts index 24f1bfd694..daffc64398 100644 --- a/package/src/skia/core/Font.ts +++ b/package/src/skia/core/Font.ts @@ -23,7 +23,7 @@ export const useFont = ( } else if (typeface && !size) { return Skia.Font(typeface); } else { - return Skia.Font(); + return null; } // eslint-disable-next-line react-hooks/exhaustive-deps }, [typeface]); From 97bdc4c8076a40605f647bd08825ce35b55987f3 Mon Sep 17 00:00:00 2001 From: chrfalch Date: Tue, 14 Jun 2022 14:13:29 +0200 Subject: [PATCH 2/2] Added simpliciation after CR --- package/src/skia/core/Font.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package/src/skia/core/Font.ts b/package/src/skia/core/Font.ts index daffc64398..f4a7348781 100644 --- a/package/src/skia/core/Font.ts +++ b/package/src/skia/core/Font.ts @@ -16,9 +16,7 @@ export const useFont = ( ): SkFont | null => { const typeface = useTypeface(font, onError); return useMemo(() => { - if (typeface === null) { - return null; - } else if (typeface && size) { + if (typeface && size) { return Skia.Font(typeface, size); } else if (typeface && !size) { return Skia.Font(typeface);