Skip to content

Reusable Custom Card Component Action Button Issue #527

Closed Answered by wwwillchen
lnarimatsu asked this question in Q&A
Discussion options

You must be logged in to vote

Take a look at: https://google.github.io/mesop/guides/interactivity/#avoid-using-closure-variables-in-event-handler

Specifically, you should change the code here:

        def redirect(e):
            print(title)
            print(path)
            if path:
                me.navigate(e.key) # use `e.key` and not `path`

        me.button(
            key=path # Add a key, so you can use it in the redirect
            button_text,
            on_click=redirect,

Unfortunately this isn't really intuitive in Mesop but it's a limitation with how event handlers are registered. Let us know if you're still running into issues.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lnarimatsu
Comment options

Answer selected by wwwillchen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants