react-redux-sweetalert
SweetAlert with Redux-style actions, reducers API
Install
$ npm install react-redux-sweetalert
Usage
;;;;; const rootReducer = ; const store = ; ;
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
;;; // eslint-disable-line static propTypes = close: PropTypesfuncisRequired swal: PropTypesfuncisRequired ; { return <div> <button onClick= thisprops >Alert</button> <ReduxSweetAlert /> </div> ; } null swal closeMain;
Checkout full examples here.
Use with ImmutableJS
;;;;;; const rootReducer = ; const store = ; ;
See full example here.
License
MIT © C.T. Lin