import React, { Children } from 'react';
import PropTypes from 'prop-types';

import Context from './context';
import Notification from './notification';

class Provider extends React.PureComponent {
  constructor(props) {
    super(props);

    this.showNotification = this.showNotification.bind(this);
  }

  showNotification(notificationOptions) {
    if (this.notification) {
      this.notification.show(notificationOptions);
    }
  }

  render() {
    return (
      <Context.Provider value={this.showNotification}>
        {Children.only(this.props.children)}
        <Notification
          ref={(ref) => {
            this.notification = ref;
          }}
          {...this.props}
        />
      </Context.Provider>
    );
  }
}

Provider.propTypes = {
  ...Notification.propTypes,
  children: PropTypes.element.isRequired,
};

export default Provider;

import React, { Children } from 'react';
import PropTypes from 'prop-types';

import Context from './context';
import Notification from './notification';

class Provider extends React.PureComponent {
  constructor(props) {
    super(props);

    this.showNotification = this.showNotification.bind(this);
  }

  showNotification(notificationOptions) {
    if (this.notification) {
      this.notification.show(notificationOptions);
    }
  }

  render() {
    return (
      <Context.Provider value={this.showNotification}>
        {Children.only(this.props.children)}
        <Notification
          ref={(ref) => {
            this.notification = ref;
          }}
        />
      </Context.Provider>
    );
  }
}

Provider.propTypes = {
  children: PropTypes.element.isRequired,
};

export default Provider;

--- 
+++ 
@@ -25,6 +25,7 @@
           ref={(ref) => {
             this.notification = ref;
           }}
+          {...this.props}
         />
       </Context.Provider>
     );
@@ -32,6 +33,7 @@
 }
 
 Provider.propTypes = {
+  ...Notification.propTypes,
   children: PropTypes.element.isRequired,
 };
 
feat(Provider): Allow passing props to 'Notification' through 'Provider'
