无法在ajax之后触发Redux操作

时间:2017-03-25 03:06:33

标签: reactjs redux

这里的React-Redux相当新。

基本上,我试图在登录成功后使用用户名更新商店。

这是JSX部分:

    <form id='loginForm' onSubmit={(e) => (this.handleSubmit(e).then(function(response){ this.props.loggedIn(this.state.username)}))}>
      <label>Login ID</label>
      <input type='text' name='username' id='username' placeholder='Enter your login ID' value={this.state.username} onChange={this.handleChangeUsername}/>
      <label>Password</label>
      <input type='password' name='password' id='password' placeholder='Enter your Password' value={this.state.password} onChange={this.handleChangePassword}/>
      <input type='submit' name='submit' value='Sign In' className="blueButton"/>
    </form>

handleSubmit()使用Axios模块返回AJAX。

我收到错误:

TypeError: Cannot read property 'props' of undefined

如果onSubmit直接设置为this.props.loggedIn.bind(null, 'sampleUsername'),则会触发操作。但是,显然没有ajax电话。

任何指针?

0 个答案:

没有答案