From 333e2b31840e4c5d91caba980ee9874125b313f3 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Thu, 6 Jul 2023 06:16:13 -0700 Subject: [PATCH] component: do not create ref for dynamic id (#1307) allow dynamic id (BaseVar) to be specified (from state value or foreach), but do not create a react reference for it, since that must be known at compile time. if a react ref is needed, then specify a string _at compile time_, not from state. fix #1302 --- reflex/components/component.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reflex/components/component.py b/reflex/components/component.py index 61b47d2f2..e538eb063 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -553,7 +553,8 @@ class Component(Base, ABC): Returns: The ref name. """ - if self.id is None: + # do not create a ref if the id is dynamic or unspecified + if self.id is None or isinstance(self.id, BaseVar): return None return format.format_ref(self.id)