Hello,
I was trying the custom components and I’m not able to remove the object after declared and instantiated.
Ex. I’m trying this example, how can I remove the login form after confirmed login?
Thanks, and have a good day!
Hello,
I was trying the custom components and I’m not able to remove the object after declared and instantiated.
Ex. I’m trying this example, how can I remove the login form after confirmed login?
Thanks, and have a good day!
Hi @enryls,
First of all, thanks for using Streamlit! and about your inquire you could solve that in different ways.
1 - Modifying the custom component itself so you can do the checking there.
2 - Solving from the python side using SessionState gist
This is an example if we took the second option:
import streamlit as st
import SessionState
import streamlit.components.v1 as components
_material_login = components.declare_component(
"material_login", url="http://localhost:3001",
)
def rerun():
raise st.script_runner.RerunException(st.script_request_queue.RerunData(None))
def material_login(title, key=None):
return _material_login(title=title, key=key)
session_state = SessionState.get(isLoggedIn=False)
USERNAME = "a@a.com"
PASSWORD = "test"
if session_state.isLoggedIn:
st.balloons()
st.header('Yay ! you are logged in')
else:
logged_in_data = material_login("Insert your account")
if bool(logged_in_data) and logged_in_data['username'] == USERNAME and logged_in_data['password'] == PASSWORD:
session_state.isLoggedIn = True
rerun()
Hi @arraydude,
Thanks for your answer, really appreciated.
I changed the react component, but I will try also something like the second example.
Thanks again and have a good day!
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.