My question is similar to the one posted here.
I use a dcc.link
as sign-in and sign-out button.
It means that I need to change the text dynamically corresponding to the authentication state (I use flask-login, i.e. current_user.is_authenticated
)
My approach is to use a callback such that everytime the dcc.link is being clicked the authentication state is being checked. If someone has logged in the dcc link should read sign out
. If noone has logged in it should read sign in
. This is the callback I wrote:
@app.callback(
Output(component_id='sign-in-out', component_property='children'),
Input(component_id='sign-in-out', component_property='children'),
)
def show_hide_element(tmp):
if current_user.is_authenticated:
return "Sign out"
else:
return "Sign in"
Unfortunately this does not work as it should. When I click sign out it does not change the text accordingly. How could I achieve this?
source https://stackoverflow.com/questions/76249478/dynamically-change-dcc-link-text
Comments
Post a Comment