✨ Announcing our seed funding led by Lux Capital! Read more about it on our blog
DocsBlogChangelog

Search documentation...

/

Star

12k+

[ Learn ]

[ Concepts ]

[ Reference ]

Component


reflex.components.component.Component
The base class for all Reflex components.

Class Fields


FieldDescription

Fields


FieldDescription
children The children nested within the component.
style The style of the component.
event_triggers A mapping from event triggers to event chains.
library The library that the component is based on.
lib_dependencies List here the non-react dependency needed by `library`
tag The tag to use when rendering the component.
alias The alias for the tag.
is_default Whether the import is default or named.
key A unique key for the component.
id The id for the component.
class_name The class name for the component.
special_props Special component props.
autofocus Whether the component should take the focus once the page is loaded
invalid_children components that cannot be children
valid_children components that are only allowed as children
custom_attrs custom attribute

Methods


SignatureDescription
__init__(self, *args, **kwargs)Initialize the component.
_create_event_chain(self, event_trigger: 'str', value: 'Union[Var, EventHandler, EventSpec, List[Union[EventHandler, EventSpec]], Callable]') -> 'Union[EventChain, Var]'Create an event chain from a variety of input types.
get_event_triggers(self) -> 'Dict[str, Any]'Get the event triggers for the component.
get_triggers(self) -> 'Set[str]'Get the triggers for non controlled events [DEPRECATED].
get_controlled_triggers(self) -> 'Dict[str, Var]'Get the event triggers that pass the component's value to the handler [DEPRECATED].
__repr__(self) -> 'str'Represent the component in React.
__str__(self) -> 'str'Represent the component in React.
_render(self) -> 'Tag'Define how to render the component in React.
add_style(self, style: 'ComponentStyle') -> 'Component'Add additional style to the component and its children.
render(self) -> 'Dict'Render the component.
_validate_component_children(self, children: 'List[Component]')Validate the children components.
_get_custom_code(self) -> 'Optional[str]'Get custom code for the component.
get_custom_code(self) -> 'Set[str]'Get custom code for the component and its children.
_get_dynamic_imports(self) -> 'Optional[str]'Get dynamic import for the component.
get_dynamic_imports(self) -> 'Set[str]'Get dynamic imports for the component and its children.
get_imports(self) -> 'imports.ImportDict'Get all the libraries and fields that are used by the component.
_get_mount_lifecycle_hook(self) -> 'str | None'Generate the component lifecycle hook.
_get_ref_hook(self) -> 'str | None'Generate the ref hook for the component.
_get_hooks_internal(self) -> 'Set[str]'Get the React hooks for this component managed by the framework. Downstream components should NOT override this method to avoid breaking framework functionality.
_get_hooks(self) -> 'Optional[str]'Get the React hooks for this component. Downstream components should override this method to add their own hooks.
get_hooks(self) -> 'Set[str]'Get the React hooks for this component and its children.
get_ref(self) -> 'Optional[str]'Get the name of the ref for the component.
get_refs(self) -> 'Set[str]'Get the refs for the children of the component.
get_custom_components(self, seen: 'Optional[Set[str]]' = None) -> 'Set[CustomComponent]'Get all the custom components used by the component.
← BaseConfig →

Copyright © 2023 Pynecone, Inc.