react-notify-mixin

0.1.0 • Public • Published

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')
);

Readme

Keywords

Package Sidebar

Install

npm i react-notify-mixin

Weekly Downloads

44

Version

0.1.0

License

MIT

Last publish

Collaborators

  • caasi