From 7156d1a0daf79dddde8ac58676af1f7eff794112 Mon Sep 17 00:00:00 2001 From: vapao Date: Fri, 22 Jan 2021 23:27:47 +0800 Subject: [PATCH] improve host Selector component --- spug_web/src/pages/host/Selector.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spug_web/src/pages/host/Selector.js b/spug_web/src/pages/host/Selector.js index b084045..e4abdaa 100644 --- a/spug_web/src/pages/host/Selector.js +++ b/spug_web/src/pages/host/Selector.js @@ -46,9 +46,14 @@ export default observer(function (props) { function handleSubmit() { if (props.onOk) { - setLoading(true) - props.onOk(group, selectedRowKeys) - .then(props.onCancel, () => setLoading(false)) + setLoading(true); + const res = props.onOk(group, selectedRowKeys); + if (res && res.then) { + res.then(props.onCancel, () => setLoading(false)) + } else { + props.onCancel(); + setLoading(false) + } } }