Skip to content

Commit

Permalink
only hit the slower path on _are_fields_known
Browse files Browse the repository at this point in the history
  • Loading branch information
adhami3310 committed Feb 14, 2025
1 parent 800b2df commit 9285005
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions reflex/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,13 +684,30 @@ def get_initial_props(cls) -> Set[str]:
"""
return set()

@classmethod
def _are_fields_known(cls) -> bool:
"""Check if all fields are known at compile time. True for most components.
Returns:
Whether all fields are known at compile time.
"""
return True

@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.
"""
if self._are_fields_known():
return tuple(
component
for name, field in self.get_fields().items()
if name in self.get_props()
and types._issubclass(field.outer_type_, Component)
for component in _components_from(getattr(self, name))
)
return [
component
for prop in self.get_props()
Expand Down Expand Up @@ -1687,6 +1704,15 @@ def __init__(self, **kwargs):
self.props[camel_cased_key] = value
setattr(self, camel_cased_key, value)

@classmethod
def _are_fields_known(cls) -> bool:
"""Check if the fields are known.
Returns:
Whether the fields are known.
"""
return False

def __eq__(self, other: Any) -> bool:
"""Check if the component is equal to another.
Expand Down

0 comments on commit 9285005

Please sign in to comment.