devNyong
react util 만들기 본문
import CustomConfirmAlert from "../components/modal/CustomConfirmAlert";
import {confirmAlert} from "react-confirm-alert";
import * as customUI from "../styles/customUI";
/*
@type : '' , SUCCESS, ERROR
@param : type , title , t ,func
@Description: 저장,수정,삭제 완료 alert
*/
export function confirmCompleteUtil (type,title,t,func) {
confirmAlert({
closeOnEscape: false, // esc 키 눌러서 닫기 여부
closeOnClickOutside: false, // 바탕화면 눌러서 닫기 여부
customUI: ({ onClose }) => {
return (
<CustomConfirmAlert
type={type}
onClose={onClose}
title={title}
buttons={[
{
label: t('common:dialogBtnOk'),
color: 'blue',
onClick: () => {func ? func() : onClose() }
}
]}
onConfirm={() => onClose()} >
</CustomConfirmAlert>
);
}
});
};
호출하는 index.jsx
import * as common from '../../lib/confirmCompleteUtil';
const save = () =>{
//저장완료 alert
common.confirmCompleteUtil('SUCCESS',t('common:dialogCompleteSave'),t);
}
'react' 카테고리의 다른 글
[React] javascript 날짜 계산 (0) | 2022.10.07 |
---|---|
[REACT] usestate 배열 추가,삭제 , 배열 바인딩 (1) | 2022.09.23 |
react-table paging (0) | 2022.05.11 |
react-table (0) | 2022.05.10 |
react 프로젝트 생성 (0) | 2022.05.03 |
Comments