1.0.2 • Published 7 years ago

react-notificator v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

react-notificator

React notification module using React-saga

How to use

  • Install with yarn add react-notificator

  • Include style

require('react-notificator/style.css')
  • Include saga and run it in your createStore.js
import {sagas as reactNotificatorSagas} from 'react-notificator'

export default function configureStore () {
  const sagaMiddleware = createSagaMiddleware()
  const mainStore = createStore(
    connectRouter(history)(reducers),
    composeEnhancers(applyMiddleware(routerMiddleware(history), sagaMiddleware))
  )

  sagaMiddleware.run(rootSagas)
  sagaMiddleware.run(reactNotificatorSagas)

  return mainStore
}
  • Add it in your main reducer
import {reducers as notificatorStore} from 'react-notificator'

export default combineReducers(
  {
    mainStore,
    notificatorStore,
  }
)
  • Connect it to store and attach it to your component

` import { component as Notificator } from './components/reactNotificator/' import { connect } from 'react-redux'

const connectNotificator = ({ notificatorStore }) => ({ notificatorStore }) const NotificatorWrapped = connect(connectNotificator)(Notificator)

class App extends React.Component{ render(){ return(

</div>)

} } `

  • Dispatch REACT_NOTIFICATOR_NOTIFY action

class App extends React.Component{ componentDidMount () { this.props.dispatch({ type : 'REACT_NOTIFICATOR_NOTIFY', payload : { message : 'foo', ms: 3000 }, }) } }

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago