🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

react-redux-sweetalert

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-redux-sweetalert

SweetAlert with redux-style actions, reducers API

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
60
11.11%
Maintainers
3
Weekly downloads
 
Created
Source

react-redux-sweetalert

NPM version Build Status Test coverage Dependency Status

SweetAlert with Redux-style actions, reducers API

Install

$ npm install react-redux-sweetalert

Usage

import React, { Component } from 'react';
import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { Provider } from 'react-redux';
import { reducer } from 'react-redux-sweetalert';

const rootReducer = combineReducers({
  sweetalert: reducer,
});

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

render(
  <Provider store={store}>
    <ReduxSweetAlert />
  </Provider>
);

You should import sweetalert.css from cdn, file, node_modules(sweetalert/dist/sweetalert.css) or wherever can find the css code.

Checkout full examples here.

API

types

Payload

{
  // sweetalert option
  title: string,
  text?: string,
  type?: string,
  customClass?: string,
  showCancelButton?: boolean,
  showConfirmButton?: boolean,
  confirmButtonText?: string,
  confirmButtonColor?: string,
  cancelButtonText?: string,
  imageUrl?: string,
  imageSize?: string,
  html?: boolean,
  animation?: boolean|string,
  inputType?: string,
  inputValue?: string,
  inputPlaceholder?: string,
  showLoaderOnConfirm?: boolean,
	
  timer?: number,
  closeOnConfirm?: boolean,
  closeOnCancel?: boolean,
  allowEscapeKey?: boolean,
  allowOutsideClick?: boolean,

  // custom option
  onConfirm?: Function,
  onCancel?: Function,
  onClose?: Function,
  onEscapeKey?: Function,
  onOutsideClick?: Function,
}

actions

swal(title: string, text: ?string, type: ?string)

swal(payload: Payload)

close()

Examples

import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import ReduxSweetAlert, { swal, close } from 'react-redux-sweetalert'; // eslint-disable-line


class Main extends Component {
  static propTypes = {
    close: PropTypes.func.isRequired,
    swal: PropTypes.func.isRequired,
  };
  render() {
    return (
      <div>
        <button
          onClick={() => this.props.swal({
            title: 'Demo',
            text: 'SweetAlert in React',
            onConfirm: this.props.close,
          })}
        >Alert</button>
        <ReduxSweetAlert />
      </div>
    );
  }
}


export default connect(null, {
  swal,
  close,
})(Main);

Checkout full examples here.

Use with ImmutableJS

import React, { Component } from 'react';
import { createStore, applyMiddleware } from 'redux';
import { combineReducers } from 'redux-immutable';
import thunk from 'redux-thunk';
import { Provider } from 'react-redux';
import { immutableReducer } from 'react-redux-sweetalert';

const rootReducer = combineReducers({
  sweetalert: immutableReducer,
});

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

render(
  <Provider store={store}>
    <ReduxSweetAlert />
  </Provider>
);

See full example here.

License

MIT © C.T. Lin

Keywords

react

FAQs

Package last updated on 24 Jul 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