Skip to content

Instantly share code, notes, and snippets.

@pbojinov
Last active May 24, 2018 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbojinov/38333608f990e8e09e9fa0cd2bde7f86 to your computer and use it in GitHub Desktop.
Save pbojinov/38333608f990e8e09e9fa0cd2bde7f86 to your computer and use it in GitHub Desktop.
/*
1. User interacts with Sender
2. Sender dispatches an action to modifiy state.deaddropto true or to any value that it wants to pass with the message.
3. Receiver has mapStateToProps with a selector for state.deaddrop, and thus gets rerendered with a new prop.
4. Receiver initiates whatever action is required.
*/
/*
I have used this pattern in my redux-form library to enable the triggering of a form submission via the dispatch of an action.
This allows the form component to know about how it needs to be submitted and validated, but also allows any actor in the entire application to trigger the submission.
Also see - https://github.com/ReactTraining/react-broadcast
*/
componentWillReceiveProps(nextProps) {
if(!this.props.deadDrop && nextProps.deadDrop) {
// dispatch an action to clear the value
this.props.clearDeadDrop()
// do what your case officer has instructed, Agent
this.performOperation(nextProps.deadDrop)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment