redirect() method is failing

3 days ago 13
ARTICLE AD BOX

I am running a reflex-based application that is intended to start at one page, then redirect to another using the redirect() method.

The code to do this is below:

import reflex as rx class State(rx.State): def next(self): print("Going to next") rx.redirect("/nextpage") def nextpage(): return rx.text("Here is the next page.",size="7") def index() -> rx.Component: return rx.container( rx.heading("Test Redirect method"), rx.text("Click on the button below to see the next page"), rx.button("Click Me",on_click=State.next), ) app = rx.App() app.add_page(index) app.add_page(nextpage,route="/nextpage")

When I run this appp, I click on the button, and the print function prints out what it should. Consequently, I know that the next() method of State is being called. Unfortunately, the redirect() method appears to do nothing. The page does not change.

I have looked for an example of how to use the redirect() method. I cannot find one. I did find an example of a login page which tells me where to use the redirect() method, but it didn't actually use it.

Am I missing something here? Does the redirect() method even work? If so, how do I get it to change to the next page?

Read Entire Article