Last active
August 29, 2015 14:01
-
-
Save Enome/5083925d40bebc9834bb to your computer and use it in GitHub Desktop.
This file contains 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
/** @jsx React.DOM */ | |
var data = arrayWithEvents; | |
var ErrorComponent = React.createClass({ | |
/* LOGIC */ | |
_update: function () { | |
this.setState({ errors: data.errors() }) | |
}, | |
/* LIFECYCLE EVENTS */ | |
componentDidMount: function () { | |
data.errors.onChange(this._update); | |
}, | |
componentWillUnmount: function () { | |
data.errors.removeListener(this._update); | |
}; | |
getInitialState: function () { | |
return { | |
errors: data.errors() | |
}; | |
}, | |
/* RENDER */ | |
render: function () { | |
return (); | |
}, | |
}); | |
var SomeComponent = React.createClass({ | |
/* LOGIC */ | |
raiseError: function () { | |
data.errors.push({ type: 'warning', msg: 'Something went wrong with this '}); | |
}, | |
/* RENDER */ | |
render: function () { | |
return ( | |
<div onClick={this.raiseError}>Error</div> | |
); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment