Notice
Recent Posts
Recent Comments
Link
«   2025/09   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Tags
more
Archives
Today
Total
관리 메뉴

devNyong

react util 만들기 본문

react

react util 만들기

devNyong 2022. 9. 21. 14:23
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