You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 28, 2026. It is now read-only.
Copy file name to clipboardExpand all lines: docs/getting_started/dashboard_tutorial.md
+16-9Lines changed: 16 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,9 +27,11 @@ You can see what the finished app and code will look like here:
27
27
28
28
29
29
```python exec
30
+
import dataclasses
30
31
from collections import Counter
31
32
32
-
classUser(rx.Base):
33
+
@dataclasses.dataclass
34
+
classUser:
33
35
"""The user model."""
34
36
35
37
name: str
@@ -181,7 +183,8 @@ rx.vstack(
181
183
import reflex as rx
182
184
from collections import Counter
183
185
184
-
classUser(rx.Base):
186
+
@dataclasses.dataclass
187
+
classUser:
185
188
"""The user model."""
186
189
187
190
name: str
@@ -616,14 +619,15 @@ So far our data has been defined in a list of lists, where the data is accessed
616
619
617
620
A better way to structure our data in Reflex is to use a class to represent a user. This way we can access the data using attributes i.e. `user.name`, `user.email`.
618
621
619
-
In Reflex when we create these classes to showcase our data, the class must inherit from `rx.Base`.
620
-
621
-
`rx.Base` is also necessary if we want to have a state var that is an iterable with different types. For example if we wanted to have `age` as an `int` we would have to use `rx.base` as we could not do this with a state var defined as `list[list[str]]`.
622
+
In Reflex when we create these classes to showcase our data, we can use dataclasses.
622
623
623
624
The `show_user` render function is also updated to access the data by named attributes, instead of indexing.
0 commit comments