Reflex Logo
Docs Logo
Api Reference

/

Componentstate

Componentstate

reflex.state.ComponentState

Base class to allow for the creation of a state instance per component.

This allows for the bundling of UI and state logic into a single class, where each instance has a separate instance of the state.

Subclass this class and define vars and event handlers in the traditional way. Then define a get_component method that returns the UI for the component instance.

See the full docs for more.

Basic example:

Fields

PropDescription
parent_state: reflex.state.BaseState | None = None
substates: dict[str, reflex.state.BaseState] = <class 'dict'>
dirty_vars: set[str] = <class 'set'>
dirty_substates: set[str] = <class 'set'>
router_data: dict[str, typing.Any] = <class 'dict'>
router: reflex.vars.base.Field[reflex.istate.data.RouterData] = <class 'reflex.istate.data.RouterData'>
is_hydrated: bool = False

Methods

SignatureDescription
get_component(cls, *children, **props) -> 'Component'Get the component instance.
create(cls, *children, **props) -> 'Component'Create a new instance of the Component.

Built with Reflex