Reputation: 4939
I am using react-redux-toastr to generate alerts in my app. These alerts are to be shown to the user for a period of time. I want to launch these messages after another actions is successfully done or failed programmatically. I am using the Readme bundled with the package.
I did the first 4 steps as indicated in the read me. To launch the message action from another action (custom) I did the following:
//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))
}
When the test action is triggered I am expecting to see the information alert with "Hello" as title and "World" as the message, but that is not the case. I don't know what I am doing wrong, or any other way to achieve my expectation.
Upvotes: 0
Views: 2144
Reputation: 30
It seems that your action creator is not right. Try this:
export function test() {
return dispatch => showMessage('Hello','World', toastInfoOption) (dispatch)
}
Upvotes: 2