From af80aaaad8be4052416481e2d6510e8a06df2503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com> Date: Thu, 20 Jul 2023 14:39:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=F0=9F=90=9B=20replace=20?= =?UTF-8?q?defaultProps=20with=20useDefaultProps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 replace defaultProps with useDefaultProps --- src/popconfirm/Popconfirm.tsx | 7 +++++-- src/popconfirm/Popcontent.tsx | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/popconfirm/Popconfirm.tsx b/src/popconfirm/Popconfirm.tsx index b93da5148..a0d1e6076 100644 --- a/src/popconfirm/Popconfirm.tsx +++ b/src/popconfirm/Popconfirm.tsx @@ -7,15 +7,19 @@ import { useLocaleReceiver } from '../locale/LocalReceiver'; import { TdPopconfirmProps, PopconfirmVisibleChangeContext } from './type'; import Popcontent from './Popcontent'; import { popconfirmDefaultProps } from './defaultProps'; +import useDefaultProps from '../hooks/useDefaultProps'; export type PopconfirmProps = TdPopconfirmProps; -const Popconfirm = forwardRef((props: PopconfirmProps, ref: React.RefObject) => { +const Popconfirm = forwardRef((originalProps, ref) => { const { classPrefix } = useConfig(); const [local, t] = useLocaleReceiver('popconfirm'); const cancelContent = typeof local.cancel === 'string' ? local.cancel : local.cancel.content; const confirmContent = typeof local.confirm === 'string' ? local.confirm : local.confirm.content; + + const props = useDefaultProps(originalProps, popconfirmDefaultProps); + const { cancelBtn = t(cancelContent), confirmBtn = t(confirmContent) } = props; const [visible, setVisible] = useControlled(props, 'visible', props.onVisibleChange); @@ -41,6 +45,5 @@ const Popconfirm = forwardRef((props: PopconfirmProps, ref: React.RefObject any }) => { +interface PopcontentProps { + onClose?: (context: PopconfirmVisibleChangeContext) => any; +} + +const Popcontent: React.FC = (props) => { const { content, cancelBtn, confirmBtn, icon, theme, onCancel = noop, onConfirm = noop, onClose = noop } = props; const { classPrefix } = useConfig();