From 7f5f20d86f7d306b340fba788aec4384bc2cb986 Mon Sep 17 00:00:00 2001 From: Yu Date: Sun, 29 Sep 2019 15:53:55 +0800 Subject: [PATCH] fix: block add modal bug (#3332) * fix: set page after list changed * fix: block add modal bug --- .../commands/block/ui/ui/Adder/index.tsx | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/umi-build-dev/src/plugins/commands/block/ui/ui/Adder/index.tsx b/packages/umi-build-dev/src/plugins/commands/block/ui/ui/Adder/index.tsx index 9789e74bdbda..7b38981597dc 100644 --- a/packages/umi-build-dev/src/plugins/commands/block/ui/ui/Adder/index.tsx +++ b/packages/umi-build-dev/src/plugins/commands/block/ui/ui/Adder/index.tsx @@ -77,16 +77,6 @@ const Adder: React.FC = props => { const [fromCheck, setFromCheck] = useState(false); const [form] = Form.useForm(); - // const [npmClients, setNpmClients] = useState(['npm']); - useEffect(() => { - if (api.detectNpmClients) { - api.detectNpmClients().then(clients => { - form.setFieldsValue({ - npmClient: clients[0], - }); - }); - } - }, []); // 展示哪个界面 // log 日志 form 表单 @@ -103,6 +93,21 @@ const Adder: React.FC = props => { }, ); + useEffect( + () => { + if (api.detectNpmClients) { + api.detectNpmClients().then(clients => { + form.setFieldsValue({ + npmClient: clients.find(c => { + return npmClients.includes(c); + }), + }); + }); + } + }, + [npmClients], + ); + useEffect(() => { /** * 成功之后清理状态 @@ -290,12 +295,14 @@ const Adder: React.FC = props => { )} - - - - + + {blockType === 'template' && ( + + + + )}