From 6a482a0f55159f4096ab43287c2f5bedc976ef40 Mon Sep 17 00:00:00 2001 From: INS Date: Mon, 18 Oct 2021 16:09:19 +0800 Subject: [PATCH] fix: Fixed confirm onClose (#64) * feat: Add `modal` component * feat: Update control params * feat: Update avatar type * feat: Update confirm * docs: Update modal docs * docs: Update confirm modal docs * fix: Fixed import path * feat: Update title and button name * feat: Add `onClose` * feat: Add `confirm` component * feat: Update control params * feat: Update avatar type * feat: Update confirm * docs: Update modal docs * feat: Add `onClose` * fix: Fixed merge an extra line --- libs/mibao-ui/src/index.ts | 1 + libs/mibao-ui/src/lib/confirm/confirm.tsx | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/mibao-ui/src/index.ts b/libs/mibao-ui/src/index.ts index 755b53b5..cef70bc9 100644 --- a/libs/mibao-ui/src/index.ts +++ b/libs/mibao-ui/src/index.ts @@ -1,5 +1,6 @@ import './index.scss' +export * from './lib/confirm/confirm' export * from './lib/select/select' export * from './lib/pagination/pagination' export * from './lib/alert/alert' diff --git a/libs/mibao-ui/src/lib/confirm/confirm.tsx b/libs/mibao-ui/src/lib/confirm/confirm.tsx index 01e7bcb0..f9e96b64 100644 --- a/libs/mibao-ui/src/lib/confirm/confirm.tsx +++ b/libs/mibao-ui/src/lib/confirm/confirm.tsx @@ -1,5 +1,5 @@ import './confirm.module.scss' -import React, { ReactNode, createContext, useState, useContext } from 'react' +import React, { ReactNode, createContext, useState, useContext, useCallback } from 'react' import { Modal, ModalBody, @@ -37,8 +37,12 @@ const ConfirmModal: React.FC<{ onClose: () => void }> = (props) => { const context = useContext(ConfirmContext) + const onClose = useCallback(() => { + context.props?.onCancel?.() + props.onClose?.() + }, [context.props, props]) - return + return {context.props?.title} @@ -57,10 +61,7 @@ const ConfirmModal: React.FC<{ { - context.props?.onCancel && }