Registry / web-framework / react-redux-toastr

react-redux-toastr

JSON →
library8.0.0jsnpmunverified

react-redux-toastr provides a robust toastr-style notification system for React applications, deeply integrating with Redux for state management. The current stable version is 8.0.0, published approximately two years ago, indicating a maintenance phase rather than active, rapid development. While the 7.x series saw several minor updates, the jump to v8 brought no explicit breaking changes documented in its changelog for the library's core API, focusing on compatibility and stability. This library differentiates itself by managing all toast notification states within the Redux store, ensuring a centralized and predictable approach. It offers extensive customization for notification positioning, animation transitions, and progress indicators, and uses an event emitter pattern for triggering toasts from any part of the application. It requires explicit Redux reducer integration and a root-level component for rendering notifications.

npm install react-redux-toastr
INSTALL
IMPORT
SIG · REACT-REDUX-TOASTR
R
react-redux-toastr
web-frameworkjavascriptv8.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ReduxToastr
import ReduxToastr from 'react-redux-toastr'
const ReduxToastr = require('react-redux-toastr')
This is the default export for the main component.
reducer
import { reducer as toastrReducer } from 'react-redux-toastr'
import { toastrReducer } from 'react-redux-toastr'
The reducer is a named export, typically aliased as 'toastrReducer' when combined with other reducers.
toastr
import { toastr } from 'react-redux-toastr'
import toastr from 'react-redux-toastr/lib/toastr'
The `toastr` emitter for triggering notifications is a named export from the main package.

This quickstart demonstrates how to set up `react-redux-toastr` by adding its reducer to the Redux store, rendering the `ReduxToastr` component at the application root, and triggering various toast messages (success, info, error, confirm) using the `toastr` emitter.

import React from 'react'; import ReactDOM from 'react-dom/client'; import { createStore, combineReducers } from 'redux'; import { Provider } from 'react-redux'; import ReduxToastr, { reducer as toastrReducer, toastr } from 'react-redux-toastr'; // Import CSS styles (mandatory) import 'react-redux-toastr/lib/css/react-redux-toastr.min.css'; // 1. Add the reducer to your Redux store const rootReducer = combineReducers({ // ... other reducers ... toastr: toastrReducer // <- Mounted at 'toastr' by default }); const store = createStore(rootReducer); // 2. Create a component to trigger toasts const MyAppComponent = () => { return ( <div> <h1>Welcome to React Redux Toastr Demo</h1> <button onClick={() => toastr.success('Success!', 'This is a success message.')}> Show Success Toast </button> <button onClick={() => toastr.info('Info', 'This is an information message.')}> Show Info Toast </button> <button onClick={() => toastr.error('Error', 'Something went wrong!', { timeOut: 0 })}> Show Error Toast (no timeout) </button> <button onClick={() => toastr.confirm('Are you sure?', { onOk: () => console.log('Confirmed'), onCancel: () => console.log('Cancelled') })}> Show Confirm Toast </button> </div> ); }; // 3. Render the ReduxToastr component at your app root const root = ReactDOM.createRoot(document.getElementById('root')); root.render( <Provider store={store}> <MyAppComponent /> <ReduxToastr timeOut={4000} newestOnTop={false} preventDuplicates position="top-right" getState={(state) => state.toastr} // Default, can be customized transitionIn="fadeIn" transitionOut="fadeOut" progressBar closeOnToastrClick /> </Provider> );
Debug
Known issues
gotchaThe CSS styles for `react-redux-toastr` are not automatically included and must be explicitly imported in your project for the toast messages to render correctly.
fix
Add `import 'react-redux-toastr/lib/css/react-redux-toastr.min.css';` to your main application entry file or ensure the SCSS file is processed by your build system.
affects: >=1.0.0
gotchaBy default, the `toastr` reducer expects to be mounted under the key `toastr` in your root Redux store (e.g., `state.toastr`). If you mount it under a different key, you must pass the `getState` prop to the `ReduxToastr` component to specify the correct path.
fix
Ensure your reducer is `toastr: toastrReducer` or set `<ReduxToastr getState={(state) => state.yourCustomKey} />` if using a different mount point.
affects: >=1.0.0
breakingWhile `react-redux-toastr` v8.0.0 did not explicitly list breaking changes in its own changelog from v7, a key peer dependency, `react-redux` v8, introduced breaking changes for React 18 compatibility, notably requiring the `useSyncExternalStore` hook. Users upgrading to `react-redux` v8 should be aware of its own migration path.
fix
Consult the `react-redux` v8 migration guide (e.g., for React 18 compatibility) and ensure your `react-redux` and `react` versions are compatible.
affects: >=8.0.0 (for react-redux)
breakingVersion 7.0.0 introduced breaking changes including adding a CSS prefix to all styles and removing `transitionIn` and `transitionOut` options directly from `confirm` methods, consolidating animation control at the main `ReduxToastr` component level.
fix
Review your CSS for `toastr` class names and adjust `confirm` configurations to use global `ReduxToastr` transition props.
affects: >=7.0.0
gotchaThe `transitionIn` and `transitionOut` props applied to the `ReduxToastr` component globally affect the animation of confirm dialogs as well, which might not always be the desired behavior if different animations are expected for toasts versus confirms.
fix
Be mindful that global transition settings will apply to confirms. Custom component options for confirms might offer more granular control if needed.
affects: >=7.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'toastr')
The `react-redux-toastr` reducer is either not mounted in the Redux store or is mounted under a different key than 'toastr' without the `getState` prop being set.
fix
Ensure `toastr: toastrReducer` is present in your `combineReducers` call, or configure `<ReduxToastr getState={(state) => state.yourCustomKey} />` if using a custom state path.
Toastr messages are dispatched but not visible on the screen, or appear unstyled.
The required CSS styles (`react-redux-toastr.min.css`) have not been imported or are not correctly loaded by the application's build system.
fix
Add `import 'react-redux-toastr/lib/css/react-redux-toastr.min.css';` to your application's entry point (e.g., `index.js` or `App.js`).
ReferenceError: toastr is not defined
The `toastr` emitter utility was not correctly imported before being used.
fix
Ensure `import { toastr } from 'react-redux-toastr';` is present in any file attempting to call `toastr.success()`, `toastr.info()`, etc.
Upgrade
Version history
8.0.0latest on npm
Audit
Dependencies
prop-typesrequiredUsed for type checking React component props.
reactrequiredCore React library for UI components.
react-reduxrequiredConnects React components to a Redux store.
reduxrequiredState management library for Redux store and reducer.
Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
2
Resources
react-redux-toastr — npm install react-redux-toastr · libregistry