sidzan sidzan - 3 months ago 25
Javascript Question

Invariant Violation : Usage Issue for npm Library

I am trying to use the react-google-login found in npm site, but i am running in to some issues . The Error is

bundle.js:3104 Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method ofLogin.


and

bundle.js:3104 Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method ofLogin


This may be because because of the usage issue . I may not have imported properly too . Any help is very much appreciated.

var React = require('react')
var GoogleLogin = require('react-google-login')
var Login = React.createClass({
responseGoogle(e){
console.log("response",e)
},
render:function(){
return <div>
<GoogleLogin
clientId="xxxxxxxxxxx-yyyyyyyyyy.apps.googleusercontent.com"
buttonText="Login"
callback={this.responseGoogle} />
</div>
},
});
module.exports = Login;


~

This is most probably calling an unwanted function or class. I have been using the require and i am not familiar with import. Any suggestions or notes on proper way of figuring out correct syntaxes on the future is also highlh appreciated.

Answer

Have you tried:

var GoogleLogin = require('react-google-login').default