question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Want to use firebaseui auth in a modal component that doesn't exist at startup; possible?

See original GitHub issue

I’m trying to enable logging into my site with firebaseui. It requires a firebaseui_auth_container to render the login form to, but I don’t have that div at startup, since it’s in a modal popup. This is my code:

    constructor() {
    ...
    // Initialize the FirebaseUI Widget using Firebase.
        var ui = new firebaseui.auth.AuthUI(Firebase.auth());
        var uiConfig = {
          'signInSuccessUrl': 'url.com',
          'signInOptions': [
            // Leave the lines as is for the providers you want to offer your users.
            Firebase.auth.GoogleAuthProvider.PROVIDER_ID,
            Firebase.auth.FacebookAuthProvider.PROVIDER_ID,
            Firebase.auth.TwitterAuthProvider.PROVIDER_ID,
            Firebase.auth.GithubAuthProvider.PROVIDER_ID,
            //Firebase.auth.EmailAuthProvider.PROVIDER_ID
          ],
          'signInFlow': 'popup'
        };
        ui.start('#firebaseui-auth-container', uiConfig)
    }

    render() {
        <div className="my-logo"><button style={{backgroundColor: 'transparent', border: '0px', 
            font: "inherit", color: "#eee", cursor:"pointer"}}
                     onClick={this.openLogin.bind(this)}>Login</button><br/></div>
                     <Modal
                       aria-labelledby='modal-label'
                       style={modalStyle}
                       backdropStyle={backdropStyle}
                       show={this.state.showLoginModal}
                       onHide={this.closeLogin.bind(this)}
                     >
                       <div id="firebaseui-auth-container" style={dialogStyle()} />
                     </Modal>
    }

The div with the appropriate ID only exists after I click the ‘login’ button in my header. Right now when I click it I get an empty modal box. Is there a way to make firebaseui ‘wait’ for the div, or to have the div ‘exist’ at startup, so that firebaseui doesn’t complain? (Right now, obviously, it throws an error saying it can’t find the widget).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
BinovaGautamcommented, Feb 7, 2018

initialize ui in a different file and import it from there. 100% working…

1reaction
PAK90commented, Jan 21, 2017

I ended up adding a ref property to the div where I wanted the logins. I then used componentDidUpdate (since the visibility of the div was based on states) and I checked for the ref property’s existence; if it wasn’t null, I could load the UI. Your answer got me started on the right path though, thanks 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use firebaseui authentication with a modal popup (ReactJS)?
Initialise the firebaseui in componentDidMount() method instead of constructor I don't see a return statement in the render function.
Read more >
Easily add sign-in to your Web app with FirebaseUI - Google
Easily add sign-in to your Web app with FirebaseUI ... FirebaseUI is a library built on top of the Firebase Authentication SDK that...
Read more >
How to Set Up FirebaseUI With Your React Application
It is advisable to initialize Firebase as early as possible. Then navigate to authentication in the Firebase project, then click on the sign-in...
Read more >
[Solved]-React: setting up firebase auth with firebase-ui-Reactjs
I ran into this issue as well most likely due to the recent issue with npm not working with the most up to...
Read more >
FirebaseUI for Web — Auth - Firebase Open Source
You first need to initialize your Firebase app. The firebase.auth.Auth instance should be passed to the constructor of firebaseui.auth.AuthUI . You can then ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found