From c2c2e3053ddc1ef280b7231686a18a0ca8c5e18d Mon Sep 17 00:00:00 2001 From: Janry Date: Thu, 14 Oct 2021 14:41:36 +0800 Subject: [PATCH] refactor(react): silent useForm for child form sence (#2302) --- packages/react/src/hooks/useForm.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/react/src/hooks/useForm.ts b/packages/react/src/hooks/useForm.ts index 35b5ca5721d..eedbb7fb55c 100644 --- a/packages/react/src/hooks/useForm.ts +++ b/packages/react/src/hooks/useForm.ts @@ -3,9 +3,5 @@ import { Form } from '@formily/core' import { FormContext } from '../shared' export const useForm = (): Form => { - const form = useContext(FormContext) - if (!form) { - throw new Error('Can not found form instance from context.') - } - return form + return useContext(FormContext) }