Last active
August 29, 2015 14:22
-
-
Save miklschmidt/dbcca2a083bf505ab7cc to your computer and use it in GitHub Desktop.
Flux and request tracking: part 1
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
class SomeComponent extends React.Component { | |
getInitialState() { | |
return { | |
requestId: null | |
} | |
} | |
createArticleSuccess() { | |
// Do stuff on success.. | |
} | |
createArticleError() { | |
// Do stuff on error.. | |
} | |
resetRequestId() { | |
this.setState({requestId: null}); | |
} | |
render() { | |
let requestTracker = null; | |
if (this.state.requestId !== null) { | |
requestTracker = <RequestTracker | |
requestId={this.state.requestId} | |
success={this.createArticleSuccess} | |
fail={this.createArticleError} | |
always={this.resetRequestId} />; | |
} | |
return <div className="my-component"> | |
<h1>Hello world</h1> | |
{requestTracker} | |
</div>; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment