Open duwerq opened 8 years ago
Hi @twolips. I am currently implementing MessageBar via Redux reducers and this is what I'm doing for it:
componentWillReceiveProps
function and add the following codecomponentWillReceiveProps (nextProps) {
const nextMessageBar = nextProps.messageBar
const { messageBar } = this.props
if (nextMessageBar && nextMessageBar.message && messageBar !== nextMessageBar) {
MessageBarManager.showAlert({...nextMessageBar})
}
}
This code will only fire when some action updates the message bar reducer thus showing what was added to this reducer. Note that the code above is pseudo code so take it with a grain of salt
@gabceb could you please illustrate this?
How exactly should I illustrate it @salhotra ? The code I posted should be enough to plug into a project
@gabceb I was able to get it to work. Thanks
I'm trying to use the ShowAlert function for logout success messages and error messages. The problem is my actions are tucked away in another file that isn't a child component of my the main parent component. Is there any way to feed the Alert action through the redux store and have RegisterMessageBar function listen for the alert? I didn't know how to classify this as a question as opposed to an issue. I realize in the documentation it specifically mentions it needs to be a child component but I still thought I'd try my luck and ask. Thanks in advance!