首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >redux/redux通知

redux/redux通知
EN

Stack Overflow用户
提问于 2017-01-24 19:46:41
回答 2查看 5.8K关注 0票数 4

我在做一个react/redux项目。我寻找一个组件或包,它向用户显示通知消息,例如反应-通知

我找到的组件(包括react notify)使用参考文献:

代码语言:javascript
复制
<ReactNotify ref='notificator'/>

如果有的话,我想要一个没有参考文献的包裹。

谢谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-01-25 05:11:53

看看redux-通知。这是一种纯redux解决方案,不需要使用refs。文档有点过时了,但这对我有用(更改就是操作)。

<Notifs />组件添加到项目的根目录中:

代码语言:javascript
复制
import { Provider }  from 'react-redux'
import { Notifs } from 'redux-notifications';

<Provider store={store}>
  <div>
    // ... other things like router ...
    <Notifs />
  </div>
</Provider>

notifReducer添加到基本减速器中:

代码语言:javascript
复制
import { createStore, combineReducers } from 'redux'
import { reducer as notifReducer } from 'redux-notifications';
combineReducers({
  notifs: notifReducer,
  // ... more reducers here ...
})

然后使用内置操作发送通知:

代码语言:javascript
复制
import { actions } from 'redux-notifications';

action.notifSend({
    message: "I am a notification",
    kind,
    id: 1234,
    dismissAfter: 2000
})(dispatch)
票数 4
EN

Stack Overflow用户

发布于 2017-01-29 15:56:51

我最近开发了一个简单的库,用于在应用程序上实现react通知系统,它不需要使用ref。看看react redux-通知。如有任何反馈,将不胜感激。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41837656

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档