Skip to content

Commit e2aab9c

Browse files
committed
revert devin changes
1 parent bf8f7ce commit e2aab9c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docs/events/decentralized_event_handlers.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ import reflex as rx
2323
class MyState(rx.State):
2424
count: int = 0
2525

26-
@rx.event
27-
def increment(self, amount: int):
28-
self.count += amount
26+
@rx.event
27+
def increment(state: MyState, amount: int):
28+
state.count += amount
2929

3030
def decentralized_event_example():
3131
return rx.vstack(
3232
rx.heading(f"Count: {MyState.count}"),
3333
rx.hstack(
34-
rx.button("Increment by 1", on_click=lambda: MyState.increment(1)),
35-
rx.button("Increment by 5", on_click=lambda: MyState.increment(5)),
36-
rx.button("Increment by 10", on_click=lambda: MyState.increment(10)),
34+
rx.button("Increment by 1", on_click=increment(1)),
35+
rx.button("Increment by 5", on_click=increment(5)),
36+
rx.button("Increment by 10", on_click=increment(10)),
3737
),
3838
spacing="4",
3939
align="center",
@@ -53,11 +53,11 @@ Here's a comparison between traditional event handlers defined within state clas
5353
# Traditional event handler within a state class
5454
class TraditionalState(rx.State):
5555
count: int = 0
56-
56+
5757
@rx.event
5858
def increment(self, amount: int = 1):
5959
self.count += amount
60-
60+
6161
# Usage in components
6262
rx.button("Increment", on_click=TraditionalState.increment(5))
6363

0 commit comments

Comments
 (0)