0.1.1 • Published 10 years ago

redux-notif v0.1.1

Weekly downloads
5
License
BSD-3-Clause
Repository
github
Last release
10 years ago

re-notif

Redux & React based Notifications center.

Docs coming soon :-)

Acknowledgement I based this off of https://github.com/indexiatech/re-notif which is an Notifications center.

Example

Store

/reducers/index.js

import { combineReducers } from 'redux';
import { notifReducer } from 'redux-notif';

const rootReducer = combineReducers({
  ...
  , notifs: notifReducer
});

export default rootReducer;

Smart Components

containers/App.js

import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { notifActions } from 'react-notif';

const { notifSend, notifClear } = notifActions;

// React component
class Demo extends React.Component {
  constructor() {
    super()
    this.state = {msg: 'hello!', kind: 'info', dismissAfter: 3000}
  }

  send() {
    this.props.notifSend({message: this.state.msg, kind: this.state.kind, dismissAfter: this.state.dismissAfter})
  }

  render() {
    return (
      <div>
        <NotifsComponent top right />

        <div className="container">
          ...
          <div onClick={::this.send}>Click me!</div>
        </div>
      </div>
    )
  }
}

// Map Redux state to component props
function mapStateToProps(state) {
  return {}
}

// Connected Component:
const App = connect(
  mapStateToProps,
  {notifSend, notifClear}
)(Demo)

export default App;
0.1.1

10 years ago

0.1.0

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago