react-notify-mixin
v0.1.0
Published
A mixin to notify the top level component.
Downloads
35
Readme
react-notify-mixin
A mixin to notify the top level component.
Usage
First, create a component with this mixin:
var NotifyMixin = require('react-notify-mixin');
var MyComp = React.createClass({
mixins: [NotifyMixin],
handleClick: function () {
this.notify('hello');
},
render: function () {
return <button onClick={this.handleClick}>click me!</button>
}
});
And bury it inside your app:
var MyApp = React.createClass({
render: function () {
return {
<div>
<div>
<MyComp />
</div>
</div>
}
}
});
Then get the notification on the top:
React.render(
<MyApp onNotify={function (msg) { doSomething(msg); }} />,
document.getElementById('app-id')
);