如何从另一个操作启动 react-redux-toastr 操作消息

How to launch a react-redux-toastr action message from another action

我正在使用 react-redux-toastr 在我的应用程序中生成警报。这些警报将在一段时间内显示给用户。我想在其他操作成功完成或以编程方式失败后启动这些消息。我正在使用与软件包捆绑在一起的 Readme

我按照自述文件中的指示执行了前 4 个步骤。要从另一个操作(自定义)启动消息操作,我执行了以下操作:

//in the '../actions/action.js' folder
import { actions } from 'react-redux-toastr'

export function showMessage(title, message, options){
  return dispatch => dispatch(actions.add({
    type: options.status,
    title,
    message,
    options
 }))
}

export const toastrInfoOption = {
  icon: 'info',
  status: 'info'
}

//I am using the thunk middleware
export function test(){
  return dispatch => dispatch(showMessage('Hello','World', toastrInfoOption))
}

当触发测试操作时,我希望看到标题为 "Hello"、消息为 "World" 的信息警报,但事实并非如此。我不知道我做错了什么,或者有什么其他方法可以达到我的期望。

看来你的action creator不对。试试这个:

 export function test() {
    return dispatch => showMessage('Hello','World', toastInfoOption)  (dispatch)
 }