Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend client_state read/write broken in 0.6.8 #4645

Open
masenf opened this issue Jan 15, 2025 · 1 comment · May be fixed by #4674
Open

Backend client_state read/write broken in 0.6.8 #4645

masenf opened this issue Jan 15, 2025 · 1 comment · May be fixed by #4674
Assignees

Comments

@masenf
Copy link
Collaborator

masenf commented Jan 15, 2025

Describe the bug
The client_state is no longer a simple value in 0.6.8, so accessing it from the backend returns an internal dictionary of values.

To Reproduce

import reflex as rx

cs = rx._x.client_state("cs", 0)


class State(rx.State):
    def be_increment(self):
        return cs.retrieve(callback=State.do_increment)

    def do_increment(self, old_value):
        print(f"{old_value=}")
        return cs.push(old_value + 1)


def counter() -> rx.Component:
    return rx.hstack(
        cs,  # needed for 0.6.7 compatibility
        rx.button(f"Client Increment: {cs.value}", on_click=cs.set_value(cs.value + 1)),
        rx.button(f"Server Increment: {cs.value}", on_click=State.be_increment),
    )

Expected behavior
Same behavior as 0.6.7: both client and server increment against the client_state var should work

Specifics (please complete the following information):

  • Python Version: 3.12.8
  • Reflex Version: 0.6.8
Copy link

linear bot commented Jan 15, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants