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

Navigate component #26

Closed
Archmonger opened this issue Oct 20, 2023 · 0 comments · Fixed by #34
Closed

Navigate component #26

Archmonger opened this issue Oct 20, 2023 · 0 comments · Fixed by #34
Assignees

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Oct 20, 2023

For event driven applications, it is useful to be able to dynamically route to different paths.

@component
def example():
    redirect_handler, set_redirect_handler = use_state(None)

    def click_event(e):
        resp = check_some_api()
        if resp.status == 501:
            set_redirect_handler(navigate("/login_incorrect"))
        elif resp.status == 200:
             set_redirect_handler(navigate("/login_successful"))
        else:
            set_redirect_handler(navigate("/login_error"))

    return div(button({"onClick": click_event}), redirect_handler)

This should be based on the react-router navigate component.

This feature might use our future use_messenger hook to handle redirection events.

@Archmonger Archmonger changed the title API to handle dynamic redirection Redirect component Jun 25, 2024
@Archmonger Archmonger changed the title Redirect component Navigate component Oct 14, 2024
@Archmonger Archmonger self-assigned this Oct 14, 2024
@Archmonger Archmonger mentioned this issue Oct 15, 2024
4 tasks
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.

1 participant