Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-toastify-redux

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-toastify-redux

react-toastify with Redux

  • 1.0.0-rc.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
214
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

React Toastify Redux Build Status npm version npm Coverage Status

Wraps react-toastify into a component and exposes actions and reducer.

Installation

$ npm install --save react-toasify-redux
$ yarn add react-toastify-redux

Usage

Import the reducer and pass it to your combineReducers:

import {combineReducers} from 'redux';
import {toastsReducer as toasts} from 'react-toasify-redux';

export default combineReducers({
    // ...other reducers
    toasts
});

Include the toast controller in main view:

import {ToastController} from 'react-toasify-redux';

export default () => {
    return (
        <div>
            ...
            <ToastController />
        </div>
    );
};

Actions

Use actions for create, update and remove toasts:

import {dismiss, update, error, message, warning, success, info} from 'react-toastify-redux';

dispatch(dismiss(id));
dispatch(dismiss()); // dismiss all toasts
dispatch(update(id, options));
dispatch(message('Default message'));
dispatch(success('Success message'));
dispatch(error('Error message'));
dispatch(warning('Warning message'));
dispatch(info('Info message'));

Customization toast

Create toast component

export default ({ type, message }) => (
    <div className='toast'>
        <div className='header'>{type}</div>
        <div className='message'>{message}</div>
    </div>
);

Include this component in ToastConroller

import {ToastController} from 'react-toasify-redux';
import CustomToastComponent from 'awesome-folder/custom-toast-component';

export default () => {
    return (
        <div>
            ...
            <ToastController toastComponent={CustomToastComponent} />
        </div>
    );
};

API

ToastContainer

ToastContainer extends properties from ToastContainer in react-toastify. Also have new properties:

PropsTypeDefaultDescription
toastComponentComponentClass or false-Element that will be displayed after emit toast

Dismiss

ParameterTypeRequiredDescription
toast idstringId toast for dismiss. If call action without id, then dismiss all toasts

Update

ParameterTypeRequiredDescription
toast idstringId toast for update
optionsobjectOptions listed below

Toast Actions (Message, Success, Info, Warning, Error)

ParameterTypeRequiredDescription
messagestringMessage for toast
optionsobjectOptions listed below

Toast Base Options

ParameterTypeDefaultDescription
renderDefaultComponentbooleanfalseRender default toast component? Use this propery if using custom toast component.
type sa# React Toastify Redux
Wraps react-toastify into a component and exposes actions and reducer.

Installation

$ npm install --save react-toasify-redux
$ yarn add react-toastify-redux

Usage

Import the reducer and pass it to your combineReducers:

import {combineReducers} from 'redux';
import {toastsReducer as toasts} from 'react-toasify-redux';

export default combineReducers({
    // ...other reducers
    toasts
});

Include the toast controller in main view:

import {ToastController} from 'react-toasify-redux';

export default () => {
    return (
        <div>
            ...
            <ToastController />
        </div>
    );
};

Actions

Use actions for create, update and remove toasts:

import {dismiss, update, error, message, warning, success, info} from 'react-toastify-redux';

dispatch(dismiss(id));
dispatch(dismiss()); // dismiss all toasts
dispatch(update(id, options));
dispatch(message('Default message'));
dispatch(success('Success message'));
dispatch(error('Error message'));
dispatch(warning('Warning message'));
dispatch(info('Info message'));

Customization toast

Create toast component

export default ({ title, message }) => (
    <div className='toast'>
        <div className='header'>{title}</div>
        <div className='message'>{message}</div>
    </div>
);

Include this component in ToastConroller

import {ToastController} from 'react-toasify-redux';
import CustomToastComponent from 'awesome-folder/custom-toast-component';

export default () => {
    return (
        <div>
            ...
            <ToastController toastComponent={CustomToastComponent} />
        </div>
    );
};

API

ToastContainer

ToastContainer extends properties from ToastContainer in react-toastify. Also have new properties:

PropsTypeDefaultDescription
toastComponentComponentClass or false-Element that will be displayed after emit toast

Dismiss

ParameterTypeRequiredDescription
toast idstringId toast for dismiss. If call action without id, then dismiss all toasts

Update

ParameterTypeRequiredDescription
toast idstringId toast for update
optionsobjectOptions listed below

Toast Actions (Message, Success, Info, Warning, Error)

ParameterTypeRequiredDescription
messagestringMessage for toast
optionsobjectOptions listed below

Toast Base Options

ParameterTypeDefaultDescription
renderDefaultComponentbooleanfalseRender default toast component? Use this propery if using custom toast component.
titlestring''Title for custom toast component
typeOne of: 'info', 'success', 'warning', 'error', 'default''default'same as ToastContainer
autoClosenumber or false5000Set the delay in ms to close the toast automatically
hideProgressBarbooleanfalseHide or show the progress bar
positionOne of: 'top-right', 'top-center', 'top-left', 'bottom-right', 'bottom-center', 'bottom-left''top-right'Set the default position to use
pauseOnHoverbooleantruePause the timer when the mouse hover the toast
classNamestring or object-An optional css class to set
bodyClassNamestring or object-same as ToastContainer
progressClassNamestring or object-same as ToastContainer
draggablebooleantrueAllow toast to be draggable
draggablePercentnumber80The percentage of the toast's width it takes for a drag to dismiss a toast

License

Licensed under MIT

Keywords

FAQs

Package last updated on 26 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc