카테고리 없음
[react] Functional Component 에서 Static Method 만들기
냐옴
2023. 2. 10. 00:05
Functional Component 정의
// ModalUtil.js
import { Modal } from "antd";
const modalConfig = {
closable: true,
maskClosable: true,
transitionName: '',
maskTransitionName: '',
centered: true,
};
function ModalUtil() {
}
ModalUtil.confirm = (content, title = '', onOk) => {
Modal.confirm({
...modalConfig,
title: title,
content: content,
okText: '예',
cancelText: '아니오',
onOk: onOk,
});
}
export default ModalUtil;
사용
ModalUtil.confirm('저장하시겠습니까?', '', () => {
//
});
https://www.frankcalise.com/static-methods-in-functional-components
Static Methods in Functional Components
Thoughts on becoming a better software engineer and bodybuilder.
www.frankcalise.com