react-social-login icon indicating copy to clipboard operation
react-social-login copied to clipboard

Unhandled Runtime Error(Google)

Open cpPratikParshuramChavan opened this issue 2 years ago • 13 comments

image

Hello All, I'm getting this error after updating my outdated packages. See the below code for implementation.

One more thing, If I remove the google button code then this issue doesn't appear. for other buttons this issue is not appearing

// login.js
<SocialButton
    provider='google'
    appId={process.env.customKey.GOOGLE_APP_ID}
    onLoginSuccess={this.handleSocialLoginSubmit}
    onLoginFailure={this.handelLoginFail}
    key={`google${socialLoginReset}`}
    className="btn google-btn"
    role="button"
> Google</SocialButton>
// SocialButton.js
import React from 'react';
import SocialLogin from 'react-social-login';
class SocialButton extends React.Component {
	render() {
		const { triggerLogin, ...props } = this.props;

		return (
			<button onClick={triggerLogin} {...props}>
				{this.props.children}
			</button>
		);
	}
}

export default SocialLogin(SocialButton);

Thanks

cpPratikParshuramChavan avatar Feb 18 '22 07:02 cpPratikParshuramChavan

Are you using next.js? Also please specify react-social-login version being used.

deepakaggarwal7 avatar Apr 09 '22 15:04 deepakaggarwal7

Also, if you can do a json.stringify of what the error is, it will be easier. I tried to fail the program through several ways, but didn't come across this error.

deepakaggarwal7 avatar Apr 09 '22 15:04 deepakaggarwal7

Are you using next.js? Also please specify react-social-login version being used.

hi there, your button is worked with nextjs ? because i dont. getting below errors

image

kurroo10 avatar Apr 19 '22 07:04 kurroo10

Error seems to come from this line of code: from https://github.com/deepakaggarwal7/react-social-login/blob/master/src/index.js, line 47

 constructor (props) {
    super(props)

    this.isStateless = !WrappedComponent.prototype.render // HERE

    this.state = {
      isLoaded: false,
      isConnected: false,
      isFetching: false
    }

I tried adding a conditional statement into: this.isStateless = WrappedComponent.prototype && !WrappedComponent.prototype.render; And now next.js can successfully build it.

ewinata avatar Apr 26 '22 01:04 ewinata

@cpPratikParshuramChavan I got same error here. @deepakaggarwal7 I am using Next.js 12.0.8 with react-social login 3.4.7.

thiefjim avatar May 03 '22 00:05 thiefjim

I've got same error.

NextJS 12.1.6 react-social-login ^3.4.15

hc0503 avatar Jun 13 '22 14:06 hc0503

Hi @deepakaggarwal7 , i am getting the same error. Versions used - NextJS: 12.2.3 react-social-login: 3.4.15

krishna-sharma-dev avatar Jul 29 '22 17:07 krishna-sharma-dev

Please check this https://codesandbox.io/s/serene-http-k3tf5 working nextjs example. Let me know if it helps? If it help you fix, please share the details in this thread.

deepakaggarwal7 avatar Sep 21 '22 03:09 deepakaggarwal7

I'm getting this same issue. It's coming from this spot in dist/social-login.js:

https://github.com/deepakaggarwal7/react-social-login/blob/cc770b45fd089b00c1990ae0bd8efa5258fb1888/dist/social-login.js#L4069

When hasCanceled_ is true and the Promise is rejected. The reason it displays as Error: [object object] is because the message passed to new Error() is an object rather than a string.

It would be nice to make this a more read-able error rather than the cryptic object that can't be read in error messages.

It looks like cancel is only called inside the componentWillUnmount method:

https://github.com/deepakaggarwal7/react-social-login/blob/cc770b45fd089b00c1990ae0bd8efa5258fb1888/src/index.js#L130

@deepakaggarwal7 Is there a reason for the error being an object { isCanceled: true } rather than a string?

I know the standard with eslint is to reject with an Error, but in this case with the way this is being used I wonder if that's really necessary? I can't think of a use case where "cancelling" the Promise chain because the component un-mounts would need to result in an error being thrown. Or where that would be desirable.

MGBR avatar Nov 01 '22 21:11 MGBR

I've used this package for google login. @react-oauth/google That works well in NextJS

hc0503 avatar Nov 03 '22 08:11 hc0503

Hi @deepakaggarwal7 , i am getting the same error. Versions used - NextJS: 12.2.3 react-social-login: 3.4.15

I updated the sandbox to use exact same version but it is working. Can you host a quick failing sandbox, so that I can fix it?

this.isStateless = WrappedComponent.prototype && !WrappedComponent.prototype.render;

I will apply this fix.

deepakaggarwal7 avatar Nov 20 '22 10:11 deepakaggarwal7

i have the same issue in next js

riyazpanarwala avatar Mar 14 '23 14:03 riyazpanarwala

only on localhost

dulguuned avatar Mar 28 '23 09:03 dulguuned