1. ์ค์น
npm install --save sweetalert2 sweetalert2-react-content
2. import ํด์ฃผ๊ธฐ
import Swal from "sweetalert2";
3. const๋ก ์ ์ธ
const deleteAlert = () => {
Swal.fire({
title: "์ผ์ ์ญ์ ",
text: "์ ๋ง๋ก ์ญ์ ํ์๊ฒ ์ด์?",
//๋ ์ด๋ฏธ์ง ์ ์ฅํด์ ์ฌ์ฉํ์ง๋ง, url๋ก ๋ถ๋ฌ์ฌ์๋์์/์ด๋ฏธ์ง ํฌ๊ธฐ ์ง์ %๋ฐ px ๋ฑ ์ฌ์ฉ์๋จ
imageUrl: calendarIcon,
imageWidth: 50,
imageHeight: 50,
//์ทจ์๋ฒํผ ํ์ ๋ฐ ๋ฒํผ ์์ ํ
์คํธ
showCancelButton: true,
confirmButtonColor: "#47AFDB",
cancelButtonColor: "#D9D9D9",
confirmButtonText: "์ญ์ ",
cancelButtonText: "์ทจ์",
});
};
4. onClick์ผ๋ก ์ฐ๊ฒฐํด์ฃผ๊ธฐ
<button onClick={deleteAlert}>์ญ์ </button>
์ด์ธ์๋ ๋ฐฐ๊ฒฝ ์ ๋ณ๊ฒฝ, ์์ด์ฝ ๋ฃ๊ธฐ ๋ฑ ๋์ฑ ๋ค์ํ๊ฒ ์ปค์คํ ๊ฐ๋ฅ ์ค์ํธ์๋ฟ2์งฑ์งฑ
์์ธํ ์ปค์คํ ๋ฐฉ๋ฒ์ ๊ณต์ ํํ์ด์ง์์
SweetAlert2
A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes
sweetalert2.github.io
GitHub - sweetalert2/sweetalert2-react-content: Official SweetAlert2 enhancer adding support for React elements as content
Official SweetAlert2 enhancer adding support for React elements as content - GitHub - sweetalert2/sweetalert2-react-content: Official SweetAlert2 enhancer adding support for React elements as content
github.com
'FA > React' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
20221001 React Hooks - useRef ๋ณ์๊ด๋ฆฌ, DOM ์์ ์ ๊ทผ (0) | 2022.10.01 |
---|---|
20220928 React์์ ์ธ์คํ ์คํ ๋ฆฌ์ฒ๋ผ ํ๊ธฐ (0) | 2022.09.28 |
22020926 React Hooks - useState, useEffect (0) | 2022.09.26 |
20220924 React์์ Dark๋ชจ๋ ์ ์ฉํ๊ธฐ (0) | 2022.09.24 |
220919 React ํ์ดํ, ์์ด์ฝ ๋ฐ๊พธ๋ ๋ฐฉ๋ฒ (0) | 2022.09.19 |