Socket
Socket
Sign inDemoInstall

sweetalert2-react-content

Package Overview
Dependencies
3
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sweetalert2-react-content

Official sweetalert2 enhancer adding support for React elements as content.


Version published
Weekly downloads
50K
decreased by-1.46%
Maintainers
2
Install size
86.6 kB
Created
Weekly downloads
 

Changelog

Source

5.0.7 (2022-10-27)

Bug Fixes

  • plugin version in dist files (c559778)

Readme

Source

sweetalert2-react-content

Official SweetAlert2 enhancer adding support for React elements as content.

Build Status npm version

semantic-release badge typescript .d.ts included License: MIT

The following options can be React elements:

  • title
  • html
  • confirmButtonText
  • denyButtonText
  • cancelButtonText
  • footer
  • closeButtonHtml
  • iconHtml
  • loaderHtml

Installation

npm install --save sweetalert2 sweetalert2-react-content

Usage Example

import Swal from 'sweetalert2'
import withReactContent from 'sweetalert2-react-content'

const MySwal = withReactContent(Swal)

MySwal.fire({
  title: <p>Hello World</p>,
  didOpen: () => {
    // `MySwal` is a subclass of `Swal` with all the same instance & static methods
    MySwal.showLoading()
  },
}).then(() => {
  return MySwal.fire(<p>Shorthand works too</p>)
})

The dist/sweetalert2-react-content.umd.js file defines window.sweetalert2ReactContent in non-CJS/AMD environments.

Limitations

SweetAlert2 renders its content outside of the ReactTree. In order to render React Router components (such as Link) you have to wrap them in the routing context which should be the same with the app.

That can be achived by using the HistoryRouter with shared history. Please refer to the official code example ↗️

Keywords

FAQs

Last updated on 27 Oct 2022

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