From 35c4987b87a673fc0da82f78086d756dec096651 Mon Sep 17 00:00:00 2001
From: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
Date: Wed, 5 Feb 2025 10:48:23 -0800
Subject: [PATCH] handle mapping as dict in type hint

---
 reflex/components/component.py |  7 +++----
 reflex/utils/types.py          | 11 +++++++++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/reflex/components/component.py b/reflex/components/component.py
index bb5f3f1c6..bfd8d8e3b 100644
--- a/reflex/components/component.py
+++ b/reflex/components/component.py
@@ -191,10 +191,6 @@ def satisfies_type_hint(obj: Any, type_hint: Any) -> bool:
     Returns:
         Whether the object satisfies the type hint.
     """
-    if isinstance(obj, LiteralVar):
-        return types._isinstance(obj._var_value, type_hint, nested=1)
-    if isinstance(obj, Var):
-        return types._issubclass(obj._var_type, type_hint)
     return types._isinstance(obj, type_hint, nested=1)
 
 
@@ -711,6 +707,9 @@ class Component(BaseComponent, ABC):
                 if isinstance(child, (tuple, list)):
                     validate_children(child)
 
+                if isinstance(child, Var):
+                    continue
+
                 # Make sure the child is a valid type.
                 if isinstance(child, dict) or not types._isinstance(
                     child, ComponentChild
diff --git a/reflex/utils/types.py b/reflex/utils/types.py
index f9c71a6df..8cf9f7335 100644
--- a/reflex/utils/types.py
+++ b/reflex/utils/types.py
@@ -565,6 +565,13 @@ def _isinstance(obj: Any, cls: GenericType, nested: int = 0) -> bool:
     if cls is Any:
         return True
 
+    from reflex.vars import LiteralVar, Var
+
+    if isinstance(obj, LiteralVar):
+        return _isinstance(obj._var_value, cls, nested=nested)
+    if isinstance(obj, Var):
+        return _issubclass(obj._var_type, cls)
+
     if cls is None or cls is type(None):
         return obj is None
 
@@ -614,8 +621,8 @@ def _isinstance(obj: Any, cls: GenericType, nested: int = 0) -> bool:
                     for item, arg in zip(obj, args, strict=True)
                 )
             )
-        if origin in (dict, Breakpoints):
-            return isinstance(obj, dict) and all(
+        if origin in (dict, Mapping, Breakpoints):
+            return isinstance(obj, Mapping) and all(
                 _isinstance(key, args[0], nested=nested - 1)
                 and _isinstance(value, args[1], nested=nested - 1)
                 for key, value in obj.items()