Estoy trabajando en un proyecto de reacción/redux. Busco un componente o un paquete que muestre mensajes de notificación al usuario, por ejemplo, react-notify .
Los componentes que he encontrado (incluido reaccionar-notificar) usan referencias:
<ReactNotify ref='notificator'/>Quiero un paquete sin referencias, si existe.
¡Gracias!
Mire redux-notifications . Es una solución redux pura sin el uso de refs . La documentación está un poco desactualizada, pero esto funcionó para mí (el cambio son las acciones).
Agrega el <Notifs /> a la raíz de su proyecto:
import { Provider } from 'react-redux' import { Notifs } from 'redux-notifications'; <Provider store={store}> <div> // ... other things like router ... <Notifs /> </div> </Provider> Agregue el notifReducer a su reductor base:
import { createStore, combineReducers } from 'redux' import { reducer as notifReducer } from 'redux-notifications'; combineReducers({ notifs: notifReducer, // ... more reducers here ... })Y luego use las acciones integradas para enviar notificaciones:
import { actions } from 'redux-notifications'; action.notifSend({ message: "I am a notification", kind, id: 1234, dismissAfter: 2000 })(dispatch)Recientemente desarrollé una biblioteca simple para implementar un sistema de notificación react-redux en su aplicación y no necesita usar ref. Échale un vistazo a react-redux-notifications . Cualquier comentario sería apreciado.