Socket
Socket
Sign inDemoInstall

react-sweetalert2-redux

Package Overview
Dependencies
3
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-sweetalert2-redux

This is an implementation of react-sweetalert2 with redux and redux-thunk


Version published
Weekly downloads
7
decreased by-50%
Maintainers
1
Install size
574 kB
Created
Weekly downloads
 

Readme

Source

react-sweetalert2-redux

Install

$ npm install react-sweetalert2-redux

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';

import ReduxSweetAlert2, { reducer } from 'react-sweetalert2-redux';

const rootReducers = combineReducers({
    sweetalert2: reducer
});

const store = createStore(
    rootReducers, 
    applyMiddleware(thunk)
);

const App = () => (
    <Provider store={store}>
        <ReduxSweetAlert2 />
    </Provider>
);

ReactDOM.render(<App/>, document.getElementById('root'));

API

Payload

{
    show: bool.isRequired,
    title?: string,
    titleText?: string,
    html?: string,
    text?: string,
    type?: enum(['warning', 'error', 'success', 'info', 'input']),
    footer?: string,
    backdrop?: boolean,
    toast?: boolean,
    target?: string,
    input?: enum(['text', 'email', 'password', 'number', 'tel', 'range', 'textarea', 'select', 'radio', 'checkbox', 'file', 'url']),
    width?: number,
    padding?: number,
    background?: string,
    position?: enum(['center', 'top', 'top-start', 'top-end', 'center-start', 'center-end', 'bottom', 'bottom-start', 'bottom-end']),
    grow?: enum(['row', 'column', 'fullscreen', false]),
    customClass?: string,
    timer?: number,
    animation?: boolean,
    heightAuto?: boolean,
    allowOutsideClick?: boolean,
    allowEscapeKey?: boolean,
    allowEnterKey?: boolean,
    stopKeydownPropagation?: boolean,
    keydownListenerCapture?: boolean,
    showConfirmButton?: boolean,
    showCancelButton?: boolean,
    confirmButtonText?: string,
    cancelButtonText?: string,
    confirmButtonColor?: string,
    cancelButtonColor?: string,
    confirmButtonClass?: string,
    cancelButtonClass?: string,
    confirmButtonAriaLabel?: string,
    cancelButtonAriaLabel?: string,
    buttonsStyling?: boolean,
    reverseButtons?: boolean,
    focusConfirm?: boolean,
    focusCancel?: boolean,
    showCloseButton?: boolean,
    closeButtonAriaLabel?: string,
    showLoaderOnConfirm?: boolean,
    preConfirm?: Function,
    imageUrl?: string,
    imageWidth?: number,
    imageHeight?: number,
    imageAlt?: string,
    imageClass?: string,
    inputPlaceholder?: string,
    inputValue?: string,
    inputOptions?: Object,
    inputAutoTrim?: boolean,
    inputAttributes?: Object,
    inputValidator?: Function,
    validationMesage?: string,
    inputClass?: string,
    progressSteps?: [],
    currentProgressStep?: string,
    progressStepsDistance?: string,
    onBeforeOpen?: Function,
    onOpen?: Function,
    onClose?: Function,
    onAfterClose?: Function,
    useRejections?: boolean,
    expectRejections?: boolean,
    onConfirm?: Function,
    showLoading?: boolean
}

Actions

openAlert(payload: Payload);
closeAlert();

Examples

import React from 'react';
import ReactDOM from 'react-dom';
import { connect } from 'react-redux';
import { createStore, combineReducers, applyMiddleware } from 'redux';
import ReduxSweetAlert2, { openAlert } from 'react-sweetalert2-redux';

class App extends Component {
    render(){
        return (
            <div>
                <button onClick={() => {
                    this.props.openAlert({
                        title: 'Hello World'
                    });
                }}>
                    Open Alert
                </button>
                <ReduxSweetAlert2 />
            </div>
        );
    }
}

export default connect(null, { openAlert })(App);

Keywords

FAQs

Last updated on 07 Jan 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc