keppelen / react-facebook-login

A Component React for Facebook Login
1.19k stars 405 forks source link

Trigger onClick event of component not works #311

Open mikethejet opened 4 years ago

mikethejet commented 4 years ago

Hi if i trying to trigger onClick event on react-facebook-login its not working any idea?

<FacebookLogin
        appId="xy"

        fields="name,email,picture"
            autoLoad={false}
        cssClass="my-facebook-button-class"
        onFailure={e => { console.warn("The fb was not initiated...") }}
        callback={this.responseFacebook}
            render={renderProps => (
             <a ref={button => this.refFacebookButton = button} href="#fb" onClick={ e=> { console.log("click na fb login"); renderProps.onClick() }} className="button blue">{t('Continue with Facebook')}</a>
            )

        }
              />

Calling in componentDidMount()

this.refFacebookButton.click();  

Initiaded as: in constructor :

this.refFacebookButton = new React.createRef();     

Display: "click na fb login" in console but window for facebook login /not open. .

zagoorland commented 3 years ago

I have the same issue...

monossido commented 2 years ago

Same issue I'm using autoLoad as workaround

bharat2913 commented 2 years ago

I'm having same issue, Does anyone figured out, what the problem is?

Quintis1212 commented 2 years ago

Hello ! This is my solution :

    const btn = document.getElementsByClassName('kep-login-facebook');
    btn[0].click();