diff --git a/reflex/components/component.py b/reflex/components/component.py index 60214a81e..0f38f73f8 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -684,19 +684,20 @@ class Component(BaseComponent, ABC): """ return set() - def _get_components_in_props(self) -> Iterator[BaseComponent]: + @lru_cache(maxsize=None) # noqa: B019 + def _get_components_in_props(self) -> Sequence[BaseComponent]: """Get the components in the props. Yields: The components in the props. """ - yield from ( + return [ component for prop in self.get_props() if (value := getattr(self, prop)) is not None and isinstance(value, (BaseComponent, Var)) for component in _components_from(value) - ) + ] @classmethod def create(cls, *children, **props) -> Self: