Преглед изворни кода

[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);
 };
 
 /**