Meteor 内部的 Redux 调度 Accounts.onEmailVerificationLink

Redux dispatch inside Meteor Accounts.onEmailVerificationLink

有没有办法在 Accounts.onEmailVerificationLink 中使用 redux 存储的 this.props.dispatch

我在 Meteor 应用程序中使用 React 和 React-redux。 验证电子邮件后,我想通过 this.props.dispatch

发送数据

我正在努力完成这项工作(如果可能的话):

Accounts.onEmailVerificationLink(function(token, done){
  console.log('onEmailVerificationLink token', token)
  console.log('this',this)
  var outerthis = this
  Accounts.verifyEmail(token, function(error){

    if(R.isNil(error)){


    }else{
      console.log('error of verifyEmail', error)
      outerthis.props.dispatch(changemainmessage(error.reason))
    }

  })

  done()
})

您需要从定义的任何地方导入您的商店对象

import store from '../config/store'

然后您可以直接从商店对象调度一个动作

store.dispatch(changemainmessage(error.reason));

Read more here

此外,我建议您对变量使用驼峰式命名法 - 它更具可读性并且遵循 JavaScript 约定

所以 changemainmessage() 将是 changeMainMessage()