-
-
Save amitmbee/cb01f8a725491b7e4d0df1b3e89a44e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function anAction () { | |
| return function (dispatch) { | |
| dispatch(requestStarted()) | |
| return fetch().then( | |
| function (success) { | |
| dispatch(requestWasSuccessful(success)); | |
| }, | |
| function (error) { | |
| dispatch(requestFailed(success)); | |
| } | |
| ); | |
| } | |
| } | |
| class SomeComponent extends Component { | |
| componentDidMount () { | |
| anAction(); | |
| } | |
| render () { | |
| const { | |
| actionData | |
| } = props; | |
| <div>Whut</div> | |
| } | |
| } | |
| // mapstatetoprops that maps the redux data to props | |
| // | |
| class SomeOtherComponent extends Component { | |
| componentDidMount () { | |
| const { actionData } = this.props; | |
| anAction().then(function(success) { | |
| // we know that this is successful, so call something that's | |
| // required. | |
| if (actionData.shouldCallTheOtherAction) { | |
| callAnotherAction(actionData.someRandomStuff) | |
| } | |
| }); | |
| } | |
| render () { | |
| const { | |
| actionData | |
| } = props; | |
| <div>Whut again</div> | |
| } | |
| } | |
| // mapstatetoprops that maps the redux data to props |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment