We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ffb86bc commit bb27be7Copy full SHA for bb27be7
3 files changed
docs/examples/useWatch.tsx
@@ -39,6 +39,7 @@ export default () => {
39
const [visible, setVisible] = useState(true);
40
const [visible2, setVisible2] = useState(true);
41
const [visible3, setVisible3] = useState(true);
42
+ const values = Form.useWatch([], form);
43
const main = Form.useWatch('main', form);
44
const age = Form.useWatch(['age'], form);
45
const demo1 = Form.useWatch(['demo1'], form);
@@ -47,7 +48,7 @@ export default () => {
47
48
const demo4 = Form.useWatch(['demo1', 'demo2', 'demo3', 'demo4'], form);
49
const demo5 = Form.useWatch(['demo1', 'demo2', 'demo3', 'demo4', 'demo5'], form);
50
const more = Form.useWatch(['age', 'name', 'gender'], form);
- console.log('main watch', demo1, demo2, main, age, demo3, demo4, demo5, more);
51
+ console.log('main watch', values, demo1, demo2, main, age, demo3, demo4, demo5, more);
52
return (
53
<>
54
<Form
src/useWatch.ts
@@ -43,6 +43,8 @@ function useWatch<TDependencies extends keyof GetGeneric<TForm>, TForm extends F
form?: TForm,
): GetGeneric<TForm>[TDependencies];
46
+function useWatch<TForm extends FormInstance>(dependencies: [], form?: TForm): GetGeneric<TForm>;
+
function useWatch<TForm extends FormInstance>(dependencies: NamePath, form?: TForm): any;
function useWatch<ValueType = Store>(dependencies: NamePath, form?: FormInstance): ValueType;
tests/useWatch.test.tsx
@@ -289,6 +289,7 @@ describe('useWatch', () => {
289
290
const Demo = () => {
291
const [form] = Form.useForm<FieldType>();
292
293
294
295
@@ -299,7 +300,9 @@ describe('useWatch', () => {
299
300
301
const demo = Form.useWatch<string>(['demo']);
302
- return <>{JSON.stringify({ main, age, demo1, demo2, demo3, demo4, demo5, more, demo })}</>;
303
+ return (
304
+ <>{JSON.stringify({ values, main, age, demo1, demo2, demo3, demo4, demo5, more, demo })}</>
305
+ );
306
};
307
308
mount(<Demo />);
0 commit comments