我在做一个react/redux项目。我寻找一个组件或包,它向用户显示通知消息,例如反应-通知。
我找到的组件(包括react notify)使用参考文献:
<ReactNotify ref='notificator'/>如果有的话,我想要一个没有参考文献的包裹。
谢谢!
发布于 2017-01-25 05:11:53
看看redux-通知。这是一种纯redux解决方案,不需要使用refs。文档有点过时了,但这对我有用(更改就是操作)。
将<Notifs />组件添加到项目的根目录中:
import { Provider } from 'react-redux'
import { Notifs } from 'redux-notifications';
<Provider store={store}>
<div>
// ... other things like router ...
<Notifs />
</div>
</Provider>将notifReducer添加到基本减速器中:
import { createStore, combineReducers } from 'redux'
import { reducer as notifReducer } from 'redux-notifications';
combineReducers({
notifs: notifReducer,
// ... more reducers here ...
})然后使用内置操作发送通知:
import { actions } from 'redux-notifications';
action.notifSend({
message: "I am a notification",
kind,
id: 1234,
dismissAfter: 2000
})(dispatch)发布于 2017-01-29 15:56:51
我最近开发了一个简单的库,用于在应用程序上实现react通知系统,它不需要使用ref。看看react redux-通知。如有任何反馈,将不胜感激。
https://stackoverflow.com/questions/41837656
复制相似问题