We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am getting below error
The text was updated successfully, but these errors were encountered:
The problem here is that event triggers inside an rx.cond do not get memoized, and need to be formatted explicitly.
rx.cond
Here is some similar repro code:
import reflex as rx class State(rx.State): v: str = "" n: int = 0 show: bool = True class FunnyButton(rx.button.__self__): def _get_hooks(self): on_click = self.event_triggers.get('on_click') if isinstance(on_click, rx.EventChain): on_click = rx.utils.format.format_prop(on_click) return f"const foo = '%s'" % on_click def index() -> rx.Component: return rx.fragment( FunnyButton.create(State.n.to_string(), on_click=State.set_n(State.n + 1)), rx.cond( State.show, FunnyButton.create(State.n.to_string(), on_click=State.set_n(State.n + 1)), rx.text("Input is hidden."), ), rx.checkbox("Show input", checked=State.show, on_change=State.set_show), ) # Create app instance and add index page. app = rx.App() app.add_page(index)
The important bit is
if isinstance(on_click, rx.EventChain): on_click = rx.utils.format.format_prop(on_click)
I updated the ResizeWatcher code in the previous discussion, but I think this is a framework bug that needs to be addressed for consistency.
ResizeWatcher
[Edited: using rx.utils.format_prop now instead of format_event_chain]
rx.utils.format_prop
format_event_chain
Sorry, something went wrong.
please update here, if you updated new codes for Resize Watcher Thank you
@kumaraguru1735 As mentioned, i updated the ResizeWatcher code in the original discussion: https://github.com/orgs/reflex-dev/discussions/2462#discussioncomment-8252786
No branches or pull requests
I am getting below error
The text was updated successfully, but these errors were encountered: