I have an issue I can’t resolve with the loading property of a button within a custom login form. I’m using a fork of the excellent repository GitHub - masenf/reflex-local-auth to make it compatible with the database I use, which is Azure SQL Server.
For the login form, I’m using the recipe included in the Reflex documentation, specifically the one called “Icons” (Login Form).
To handle the submit, I encapsulate it in a form like this:
def login_card() -> rx.Component:
return rx.form(
rx.card(
rx.vstack(
rx.center(
rx.image(
src="/logo.png",
...
)
),
...
),
# on_submit=LoginState.on_submit,
on_submit=State.handle_login_submit, # I encapsulate the reflex_local_auth on_submit function in this handle_login_submit function to manage the boolean state of is_loading_login
)
)
Notice that I’m not directly calling on_submit from reflex-local-auth; instead, I’ll do this through another function to avoid modifying the included repository code, making future maintenance easier.
The code for that function is:
@rx.event
def handle_login_submit(self, form_data: dict):
self.is_loading_login = True
yield
try:
login_result = LoginState.on_submit(form_data)
yield login_result
finally:
self.is_loading_login = False
yield
This function is in my state.py .
I’m not sure what I’m doing wrong, but yield isn’t working as expected. The login page doesn’t refresh, and the button doesn’t show its loading state.