Skip to content

Commit 0c5f00a

Browse files
committed
remove reflex base
1 parent 373213e commit 0c5f00a

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

docs/getting_started/dashboard_tutorial.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ In this tutorial, you are building an interactive data dashboard with Reflex.
2424
You can see what the finished app and code will look like here:
2525

2626
```python exec
27+
import dataclasses
2728
from collections import Counter
2829

29-
class User(rx.Base):
30+
@dataclasses.dataclass
31+
class User:
3032
"""The user model."""
3133

3234
name: str
@@ -178,7 +180,8 @@ rx.vstack(
178180
import reflex as rx
179181
from collections import Counter
180182

181-
class User(rx.Base):
183+
@dataclasses.dataclass
184+
class User:
182185
"""The user model."""
183186

184187
name: str
@@ -610,14 +613,15 @@ So far our data has been defined in a list of lists, where the data is accessed
610613

611614
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`.
612615

613-
In Reflex when we create these classes to showcase our data, the class must inherit from `rx.Base`.
614-
615-
`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]]`.
616+
In Reflex when we create these classes to showcase our data, we can use dataclasses.
616617

617618
The `show_user` render function is also updated to access the data by named attributes, instead of indexing.
618619

619620
```python exec
620-
class User(rx.Base):
621+
import dataclasses
622+
623+
@dataclasses.dataclass
624+
class User:
621625
"""The user model."""
622626

623627
name: str
@@ -663,7 +667,8 @@ rx.table.root(
663667
```
664668

665669
```python
666-
class User(rx.Base):
670+
@dataclasses.dataclass
671+
class User:
667672
"""The user model."""
668673

669674
name: str
@@ -1105,7 +1110,8 @@ rx.vstack(
11051110
```
11061111

11071112
```python
1108-
class User(rx.Base):
1113+
@dataclasses.dataclass
1114+
class User:
11091115
"""The user model."""
11101116

11111117
name: str
@@ -1643,7 +1649,8 @@ rx.vstack(
16431649
import reflex as rx
16441650
from collections import Counter
16451651

1646-
class User(rx.Base):
1652+
@dataclasses.dataclass
1653+
class User:
16471654
"""The user model."""
16481655

16491656
name: str

0 commit comments

Comments
 (0)