Browse Source

chore: useFormState support literal type (#1232)

Shuaiqi Wang 3 years ago
parent
commit
0e480522bb
1 changed files with 3 additions and 2 deletions
  1. 3 2
      packages/semi-ui/form/hooks/useFormState.tsx

+ 3 - 2
packages/semi-ui/form/hooks/useFormState.tsx

@@ -1,8 +1,9 @@
+import { FormState } from '@douyinfe/semi-foundation/form/interface';
 import React, { useContext } from 'react';
 import { FormStateContext } from '../context';
 
-function useFormState() {
-    const formState = useContext(FormStateContext);
+function useFormState<T extends Record<string, any> = any>() {
+    const formState = useContext<FormState<T>>(FormStateContext);
     return formState;
 }