Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/state_structure/component_state.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,14 @@ def extended_counter():
),
)
```

## Saving Vars and Event Handlers

Creating a new instance of a `ComponentState` creates a new subclass of the
`ComponentState`, so `ClassVar` annotated attributes should be used to store
event handlers or other references to other state vars that are common for all
users.

For example, when a `ComponentState` needs to accept an event handler as a
callback or accept another state var as a prop, these can be stored on the `cls`
from within `get_component`.