瀏覽代碼

fix dynamic components removing all imports form the library (#5008)

Khaleel Al-Adhami 1 月之前
父節點
當前提交
593b0c15e0
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      reflex/components/component.py

+ 6 - 3
reflex/components/component.py

@@ -2,6 +2,7 @@
 
 from __future__ import annotations
 
+import contextlib
 import copy
 import dataclasses
 import functools
@@ -1974,13 +1975,15 @@ class NoSSRComponent(Component):
         # Do NOT import the main library/tag statically.
         import_name = self._get_import_name()
         if import_name is not None:
-            _imports[import_name] = [
+            with contextlib.suppress(ValueError):
+                _imports[import_name].remove(self.import_var)
+            _imports[import_name].append(
                 imports.ImportVar(
                     tag=None,
                     render=False,
                     transpile=self._should_transpile(self.library),
-                ),
-            ]
+                )
+            )
 
         return imports.merge_imports(
             dynamic_import,