Skip to content

Commit dcdc06e

Browse files
committed
Handle value not an object in isTextStyleObject
1 parent da5288f commit dcdc06e

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

packages/theme/src/utils.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@ import { isObject } from "lodash";
22
import type { ThemeValues } from "./types";
33

44
export function isTextStyleObject(value: any): boolean {
5-
return Object.keys(value).some((key) =>
6-
[
7-
"fontFamily",
8-
"fontWeight",
9-
"fontSize",
10-
"fontStyle",
11-
"lineHeight",
12-
"letterSpacing",
13-
].includes(key)
14-
);
5+
try {
6+
return Object.keys(value).some((key) =>
7+
[
8+
"fontFamily",
9+
"fontWeight",
10+
"fontSize",
11+
"fontStyle",
12+
"lineHeight",
13+
"letterSpacing",
14+
].includes(key)
15+
);
16+
} catch (e) {
17+
// If `value` is not an object, the above code will throw an error
18+
// Catch error and return false is more efficient than a call to `isObject`
19+
return false;
20+
}
1521
}
1622

1723
export function asThemeValuesObject(value: any): ThemeValues | null {

0 commit comments

Comments
 (0)