Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var ApiRequestMixin = function(url, success, error) {
- apiRequestIds: [],
- componentDidMount: function() {
- var requestId = api.request(url, {
- success: success.bind(this),
- error: error.bind(this)
- });
- this.apiRequestIds.push(requestId);
- },
- componentWillUnmount: function() {
- api.cancelRequests(this.apiRequestIds);
- },
- }
- React.createClass({
- mixins: [
- ApiRequestMixin('http://...',
- function() {
- success...
- },
- function() {
- error...
- }
- ],
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement