|
@@ -22,7 +22,7 @@ from reflex.event import (
|
|
)
|
|
)
|
|
from reflex.style import Style
|
|
from reflex.style import Style
|
|
from reflex.utils import format, imports, types
|
|
from reflex.utils import format, imports, types
|
|
-from reflex.vars import BaseVar, ImportVar, NoRenderImportVar, Var
|
|
|
|
|
|
+from reflex.vars import BaseVar, ImportVar, Var
|
|
|
|
|
|
|
|
|
|
class Component(Base, ABC):
|
|
class Component(Base, ABC):
|
|
@@ -546,13 +546,16 @@ class Component(Base, ABC):
|
|
# Return the dynamic imports
|
|
# Return the dynamic imports
|
|
return dynamic_imports
|
|
return dynamic_imports
|
|
|
|
|
|
|
|
+ def _get_dependencies_imports(self):
|
|
|
|
+ return {
|
|
|
|
+ dep: {ImportVar(tag=None, render=False)} for dep in self.lib_dependencies
|
|
|
|
+ }
|
|
|
|
+
|
|
def _get_imports(self) -> imports.ImportDict:
|
|
def _get_imports(self) -> imports.ImportDict:
|
|
imports = {}
|
|
imports = {}
|
|
if self.library is not None and self.tag is not None:
|
|
if self.library is not None and self.tag is not None:
|
|
imports[self.library] = {self.import_var}
|
|
imports[self.library] = {self.import_var}
|
|
- for dep in self.lib_dependencies:
|
|
|
|
- imports[dep] = {NoRenderImportVar()} # type: ignore
|
|
|
|
- return imports
|
|
|
|
|
|
+ return {**imports, **self._get_dependencies_imports()}
|
|
|
|
|
|
def get_imports(self) -> imports.ImportDict:
|
|
def get_imports(self) -> imports.ImportDict:
|
|
"""Get all the libraries and fields that are used by the component.
|
|
"""Get all the libraries and fields that are used by the component.
|
|
@@ -870,10 +873,11 @@ class NoSSRComponent(Component):
|
|
def _get_imports(self):
|
|
def _get_imports(self):
|
|
imports = {"next/dynamic": {ImportVar(tag="dynamic", is_default=True)}}
|
|
imports = {"next/dynamic": {ImportVar(tag="dynamic", is_default=True)}}
|
|
|
|
|
|
- for dep in [self.library, *self.lib_dependencies]:
|
|
|
|
- imports[dep] = {NoRenderImportVar()} # type: ignore
|
|
|
|
-
|
|
|
|
- return imports
|
|
|
|
|
|
+ return {
|
|
|
|
+ **imports,
|
|
|
|
+ self.library: {ImportVar(tag=None, render=False)},
|
|
|
|
+ **self._get_dependencies_imports(),
|
|
|
|
+ }
|
|
|
|
|
|
def _get_dynamic_imports(self) -> str:
|
|
def _get_dynamic_imports(self) -> str:
|
|
opts_fragment = ", { ssr: false });"
|
|
opts_fragment = ", { ssr: false });"
|