Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

221
Vistas
How to Remove element using react when a user is logged in?

I have the following react code:

export class LoginButton extends React.Component {
render() {
    return (
        <img id="logInButton" src="\assets\btn_google_signin_dark_focus_web@2x.png" onClick={() => { signIn() }}></img >
    );
}}
ReactDOM.render(<LoginButton />, document.getElementById('logInRoot'));

And HTML code:

<body>
    <div id="logInRoot"></div>
</body>

When the signIn() function is called, the google sign in UI from Firebase appears and the user logs in.

What I need to do is make the div with id "logInRoot" disappear. Then reappear if the user logs out again.

Here is my code for signIn():

export const auth = getAuth();
export function signIn() {
signInWithPopup(auth, provider)
    .then((result) => {
        // This gives you a Google Access Token. You can use it to access the Google API.
        const credential = GoogleAuthProvider.credentialFromResult(result);
        const token = credential.accessToken;
        // The signed-in user info.
        const user = result.user;
        // ...
    }).catch((error) => {
        // Handle Errors here.
        const errorCode = error.code;
        const errorMessage = error.message;
        // The email of the user's account used.
        const email = error.email;
        // The AuthCredential type that was used.
        const credential = GoogleAuthProvider.credentialFromError(error);
        // ...
    });
}

Can someone please tell me how I go about doing this?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda