import React, { Component } from 'react';
import AuthStore from './stores/AuthStore.js';
import AuthActions from './actions/AuthActions.js';
import connectToStores from 'alt/utils/connectToStores';
//import statics from 'alt/utils/statics';
class Login extends Component {
constructor(){
super();
}
static getStores() {
return [AuthStore];
}
static getPropsFromStores() {
return AuthStore.getState();
}
onClickLogin() {
AuthActions.login({
username: this.refs.usernameInput.value,
password: this.refs.passwordInput.value
});
}
render() {
let divError = (AuthStore.getState().error) ? (<p>
{AuthStore.getState().error}</p>) : null;
return (
<div>
<input ref="usernameInput" placeholder="Username" type="text" />
<input ref="passwordInput" placeholder="Password" type="password" />
<button onClick={this.onClickLogin.bind(this)}
type="button">Login</button>
{divError}
</div>
);
}
}
export default connectToStores(Login);
我已经检查了github上的一些代码,它看起来完全一样,我不知道发生了什么,整个星期天花了我整个时间,但仍然无法正常工作。 这是错误消息:
TypeError:_react2.default.createClass不是一个函数 (匿名功能) C:/XYZ/XYZ/code/webapp/node_modules/alt/utils/connectToStores.js:71
68 |抛出新的错误(“ connectToStores()期望包装的组件具有静态的getPropsFromStores()方法”);
69 | }
70 |
71 | var StoreConnection = _react2 ['default']。createClass({
72 | displayName:“状态” +(Component.displayName || Component.name ||“容器”),
73 |