【发布时间】:2016-12-19 08:42:11
【问题描述】:
我正在尝试使用在 npm site 中找到的 react-google-login,但我遇到了一些问题。错误是
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.
和
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
这可能是因为使用问题。我也可能没有正确导入。非常感谢任何帮助。
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;
~
这很可能是调用了不需要的函数或类。我一直在使用require,但我不熟悉导入。任何有关在未来找出正确语法的正确方法的建议或注释也非常感谢。
【问题讨论】:
标签: javascript node.js reactjs import babeljs