Skip to content

Reflex ClientStateVar.set_value sets to undefined #6706

Description

@tim-haselhoff

Describe the bug
A clear and concise description of what the bug is.
On click of the menu_trigger _on_open_change sets the value of the ClientStateVar to undefined instead of True

Is this a bug or am I just using call_function incorrectly with set_value?

To Reproduce
Steps to reproduce the behavior:

import reflex as rx
from reflex.event import EventSpec
from reflex.experimental import ClientStateVar

loading = ClientStateVar.create(default=False)


def index() -> rx.Component:
    def _on_open_change(is_open: rx.Var[bool]) -> list[EventSpec]:
        return [
            rx.call_function(loading.set_value(is_open)),
        ]

    return rx.el.div(
        rx.text(loading.value.to_string()),
        rx.menu.root(
            rx.menu.trigger(rx.button("open")),
            rx.menu.content(rx.text("hello :)")),
            on_open_change=_on_open_change,
        ),
    )


app = rx.App()
app.add_page(index)
  • Code/Link to Repo:

Expected behavior
A clear and concise description of what you expected to happen.
_on_open_change sets the ClientStateVar to is_open.

Screenshots
If applicable, add screenshots to help explain your problem.

Specifics (please complete the following information):

  • Python Version: 1.14.6
  • Reflex Version: 0.9.6
  • OS: Linux
  • Browser (Optional): Chromium

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions