diff --git a/packages/theme/src/utils.ts b/packages/theme/src/utils.ts index ef8b24fd1..a9e51ebee 100644 --- a/packages/theme/src/utils.ts +++ b/packages/theme/src/utils.ts @@ -2,16 +2,22 @@ import { isObject } from "lodash"; import type { ThemeValues } from "./types"; export function isTextStyleObject(value: any): boolean { - return Object.keys(value).some((key) => - [ - "fontFamily", - "fontWeight", - "fontSize", - "fontStyle", - "lineHeight", - "letterSpacing", - ].includes(key) - ); + try { + return Object.keys(value).some((key) => + [ + "fontFamily", + "fontWeight", + "fontSize", + "fontStyle", + "lineHeight", + "letterSpacing", + ].includes(key) + ); + } catch (e) { + // If `value` is not an object, the above code will throw an error + // Catch error and return false is more efficient than a call to `isObject` + return false; + } } export function asThemeValuesObject(value: any): ThemeValues | null {