Detalhes do pacote

sweetalert2-react-content

sweetalert2281.2kMIT5.1.0

Official sweetalert2 enhancer adding support for React elements as content.

sweetalert, sweetalert2, react, content

readme (leia-me)

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 ↗️

changelog (log de mudanças)

5.1.0 (2024-12-16)

Features

5.0.7 (2022-10-27)

Bug Fixes

  • plugin version in dist files (c559778)

5.0.6 (2022-10-27)

Bug Fixes

  • use @rollup/plugin-terser (8f4f44f)

5.0.5 (2022-10-19)

Bug Fixes

5.0.4 (2022-10-19)

Bug Fixes

5.0.3 (2022-08-17)

Bug Fixes

  • export type ReactSweetAlertOptions (closes #208) (b3564da)

5.0.2 (2022-07-22)

Bug Fixes

  • use react-dom/client in rollup config (#205) (4ce9ca9)

5.0.1 (2022-06-28)

Bug Fixes

  • pass process.env.NODE_ENV=production to rollup build config (734daa4)

5.0.0 (2022-04-12)

  • BREAKING CHANGE: React 18 🎉 (#189) (978586a), closes #189

BREAKING CHANGES

  • React 18 🎉

4.2.0 (2021-10-18)

Features

4.1.1 (2021-07-22)

Bug Fixes

  • types: add missing types for .mixin() (#173) (2a35c97)

4.1.0 (2021-06-20)

Features

4.0.1 (2021-05-19)

Bug Fixes

4.0.0 (2021-05-17)

  • BREAKING CHANGE: Drop IE11 and legacy Edge support (#166) (e5a0e6b), closes #166

BREAKING CHANGES

  • Drop IE11 and legacy Edge support

3.3.3 (2021-05-16)

Bug Fixes

  • support sweetalert2@v11 (87350d0)

3.3.2 (2021-04-20)

Bug Fixes

3.3.1 (2021-02-18)

Bug Fixes

3.3.0 (2021-02-12)

Features

3.2.2 (2020-11-27)

Bug Fixes

3.2.1 (2020-10-13)

Bug Fixes

  • use didOpen and didDestroy instead of deprecated onOpen and onDestroy (#126) (ce0f62d)

3.2.0 (2020-09-08)

Features

  • add denyButtonText mount, support SweetAlert2 v10 🚀 (#124) (0fcfee7)

3.1.0 (2020-09-02)

Features

3.0.3 (2020-07-12)

Bug Fixes

  • update typescript declaration file for TS 3.9.5 (#119) (757ab23)

3.0.2 (2020-07-12)

Bug Fixes

3.0.1 (2020-02-20)

Bug Fixes

  • unmountComponentAtNode(...): Target container is not a DOM elementd fyf (#108) (c592b0c)

3.0.0 (2020-01-27)

  • BREAKING CHANGE: fix: Unmount React content only once popup is destroyed (#107) (2061d64), closes #107

BREAKING CHANGES

  • fix: Unmount React content only once popup is destroyed (#107)

2.0.2 (2019-11-08)

Bug Fixes

  • call super method /w given arg when extending onOpen & onClose (#101) (4362bdc)

2.0.1 (2019-11-07)

Bug Fixes

  • dom: mount html content inside element used for html content (#58) (3101894)

2.0.0 (2019-11-05)

  • BREAKING CHANGE: sweetalert2 v9 (519bcd8)

BREAKING CHANGES

  • sweetalert2 v9

1.1.0 (2019-03-23)

Features

  • package: add ^8.2.2 to version range for sweetalert2 peer dep (a39a635)
  • update-method: throw error when swal.update() is called (e442747)

1.0.3 (2019-02-20)

Bug Fixes

  • changelog: add missing changelog entry for v1.0.2 (#77) (915e624)

1.0.2 (2019-02-20)

Bug Fixes

  • banner: fix version number in banner comment, closes #48 (#74) (a30f59b)

1.0.1 (2018-06-18)

Bug Fixes

  • typescript: replace Diff type with new built-in Exclude type (#43) (973b68b)

1.0.0 (2018-03-27)

Bug Fixes

  • api: be a normal enhancer, require the Swal argument (no default) (a331c59)

Features

  • api: integrate changes from sweetalert2/sweetalert2#1036 (b661367)

BREAKING CHANGES

  • api: no default value for the Swal argument

0.5.0 (2018-03-19)

Features

  • typescript: add TypeScript type definitions (#15) (5d2204e)

0.4.0 (2018-03-13)

Bug Fixes

  • package: fix "homepage" and "bugs" fields (c386eaf)

Features

  • package: include a variety of module formats, minified and non-minified, with sourcemaps (#17) (8e98938)

0.3.1 (2018-03-08)

Bug Fixes

  • package: exclude eslint configuration from published package (4fb31c8)

0.3.0 (2018-03-08)

Features

  • package: improve filenames (5cea0c0)
  • package: use es modules (af47116)

0.2.3 (2018-03-07)

Bug Fixes

  • build: Fix webpack externals config to use correct package names in CJS environments, closes #9 (1063416)

0.2.2 (2018-03-07)

Bug Fixes

  • api: Don't accept an options object, YAGNI (#11) (f101444)