浏览代码

[ENG-3833] handle object in is bool (#3974)

* handle object in is bool

* use if statements
Khaleel Al-Adhami 7 月之前
父节点
当前提交
00d995d971
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      reflex/.templates/web/utils/state.js

+ 3 - 1
reflex/.templates/web/utils/state.js

@@ -832,7 +832,9 @@ export const useEventLoop = (
  * @returns True if the value is truthy, false otherwise.
  */
 export const isTrue = (val) => {
-  return Array.isArray(val) ? val.length > 0 : !!val;
+  if (Array.isArray(val)) return val.length > 0;
+  if (val === Object(val)) return Object.keys(val).length > 0;
+  return Boolean(val);
 };
 
 /**