Gathering detailed insights and metrics for react-sweetalert2
Gathering detailed insights and metrics for react-sweetalert2
Gathering detailed insights and metrics for react-sweetalert2
Gathering detailed insights and metrics for react-sweetalert2
sweetalert2
A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes, supported fork of sweetalert
sweetalert2-react-content
Official sweetalert2 enhancer adding support for React elements as content.
vue-sweetalert2
Simple Vue sweetalert2 package
@sweetalert2/theme-bootstrap-4
Bootstrap 4 theme for SweetAlert2
npm install react-sweetalert2
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
14 Stars
48 Commits
2 Forks
3 Watching
10 Branches
2 Contributors
Updated on 16 Aug 2024
Minified
Minified + Gzipped
TypeScript (93.55%)
JavaScript (6.45%)
Cumulative downloads
Total Downloads
Last day
-1.8%
1,178
Compared to previous day
Last week
-1.5%
7,140
Compared to previous week
Last month
3.3%
30,882
Compared to previous month
Last year
207.7%
278,488
Compared to previous year
$ npm i react-sweetalert2
or
$ yarn add react-sweetalert2
1 2import React, { useState } from 'react'; 3import SweetAlert2 from 'react-sweetalert2'; 4 5export default function App(){ 6 const [swalProps, setSwalProps] = useState({}); 7 return ( 8 <div> 9 <button onClick={() => { 10 setSwalProps({ 11 show: true, 12 title: 'Basic Usage', 13 text: 'Hello World', 14 }); 15 }}> 16 Open 17 </button> 18 19 <SweetAlert2 {...swalProps} /> 20 </div> 21 ); 22} 23
1import React, { Component } from 'react'; 2import SweetAlert2 from 'react-sweetalert2'; 3 4export default class App extends Component{ 5 constructor(){ 6 super(); 7 8 this.state = { 9 swal: {} 10 } 11 } 12 13 render() { 14 return ( 15 <div> 16 <button onClick={() => { 17 this.setState({ 18 swal: { 19 show: true, 20 title: 'Basic Usage', 21 text: 'Hello World' 22 } 23 }); 24 }}>Alert</button> 25 <SweetAlert2 {...this.state.swal} /> 26 </div> 27 ); 28 } 29} 30 31 32
withSwal
functionswal
props into Functional Component1import React from 'react'; 2import { withSwal } from 'react-sweetalert2'; 3 4export default withSwal((props, ref) => { 5 const { swal, ...rest } = props; 6 7 function handleClick(){ 8 swal.fire({ 9 title: 'Example', 10 text: 'Swal injected', 11 icon: 'success', 12 }); 13 } 14 15 return ( 16 <button onClick={handleClick}> 17 Open 18 </button> 19 ); 20}); 21
swal
props into Class Component1import React from 'react'; 2import { withSwal } from 'react-sweetalert2'; 3 4class ExampleComponent extends Component { 5 6 function handleClick(){ 7 this.swal.fire({ 8 title: 'Example', 9 text: 'Swal injected', 10 icon: 'success', 11 }); 12 } 13 14 render(){ 15 return ( 16 <button onClick={this.handleClick.bind(this)}> 17 Open 18 </button> 19 ); 20 } 21} 22 23export default withSwal(ExampleComponent); 24
SweetAlert2
component1import React, { useState } from 'react'; 2import SweetAlert2 from 'react-sweetalert2'; 3 4export default function App(){ 5 const [swalProps, setSwalProps] = useState({}); 6 7 function handleClick(){ 8 setSwalProps({ 9 show: true, 10 title: 'Example', 11 text: 'Hello World', 12 }); 13 } 14 15 return ( 16 <div> 17 <button onClick={handleClick}> 18 Alert 19 </button> 20 <SweetAlert2 {...swalProps} 21 didOpen={() => { 22 // run when swal is opened... 23 }} 24 didClose={() => { 25 // run when swal is closed... 26 }} 27 onConfirm={result => { 28 // run when clieked in confirm and promise is resolved... 29 }} 30 onError={error => { 31 // run when promise rejected... 32 }} 33 onResolve={result => { 34 // run when promise is resolved... 35 }} 36 /> 37 </div> 38 ); 39}
swal
prop injected1import React from 'react'; 2import { withSwal } from 'react-sweetalert2'; 3 4export default withSwal(({ swal }, ref) => ( 5 <button onClick={e => { 6 swal.fire({ 7 title: 'Example', 8 text: 'Hello World', 9 didOpen: () => { 10 // run when swal is opened... 11 }, 12 didClose: () => { 13 // run when swal is closed... 14 } 15 }).then(result => { 16 // when confirmed and promise resolved... 17 }).catch(error => { 18 // when promise rejected... 19 }); 20 }}> 21 Show Alert 22 </button> 23)); 24
1import React, { useState } from 'react'; 2import SweetAlert2 from 'react-sweetalert2'; 3 4export default function App(){ 5 const [swalProps, setSwalProps] = useState({}); 6 7 function handleClick(){ 8 setSwalProps({ 9 show: true, 10 title: 'Example' 11 }); 12 } 13 14 return ( 15 <div> 16 <button onClick={handleClick}> 17 Alert 18 </button> 19 <SweetAlert2 {...swalProps}> 20 <h1> 21 Hello World! 22 </h1> 23 </SweetAlert2> 24 </div> 25 ); 26} 27
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/26 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
14 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More