New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't wrap arrow functions #158
Comments
Could you please share sample code? I agree that prototype isn't available for arrow functions, but I created one which worked. If you share your breaking usage, I might be able to fix it sooner. |
same for me on nextjs, here's the following component that i created import { FC, ReactNode } from 'react';
import SocialLogin from 'react-social-login';
type ISocialButtonProps = {
children: ReactNode;
props: any;
triggerLogin: any;
};
const SocialButton: FC = (props: ISocialButtonProps) => {
const { triggerLogin, children, ...otherProps } = props;
return (
<button onClick={triggerLogin} {...otherProps}>
{children}
</button>
);
};
export default SocialLogin(SocialButton); code above throw me an error : TypeError: Cannot read property 'render' of undefined which coming from this line of code: // node_modules/react-social-login/dist/social-login.js line 979
_this.isStateless = !WrappedComponent.prototype.render; |
i did converting my Arrow function to a Class component, and its working. here's the code , maybe someone in future needed it. import React, { Component, ReactNode } from 'react';
import SocialLogin from 'react-social-login';
type ISocialButtonProps = {
children: ReactNode;
props: any;
triggerLogin: any;
};
export class SocialButton extends Component<ISocialButtonProps> {
render() {
return (
<button onClick={this.props.triggerLogin} {...this.props}>
{this.props.children}
</button>
);
}
}
export default SocialLogin(SocialButton); |
It gives
The problem is that arrow functions don't have a prototype and therefore the stateless component test throws
TypeError
.see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
https://github.com/deepakaggarwal7/react-social-login/blob/master/src/index.js#L48
The text was updated successfully, but these errors were encountered: