Skip to content

Commit bb27be7

Browse files
authored
fix: all ts (#418)
* fix: all ts * fix: all ts
1 parent ffb86bc commit bb27be7

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

docs/examples/useWatch.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default () => {
3939
const [visible, setVisible] = useState(true);
4040
const [visible2, setVisible2] = useState(true);
4141
const [visible3, setVisible3] = useState(true);
42+
const values = Form.useWatch([], form);
4243
const main = Form.useWatch('main', form);
4344
const age = Form.useWatch(['age'], form);
4445
const demo1 = Form.useWatch(['demo1'], form);
@@ -47,7 +48,7 @@ export default () => {
4748
const demo4 = Form.useWatch(['demo1', 'demo2', 'demo3', 'demo4'], form);
4849
const demo5 = Form.useWatch(['demo1', 'demo2', 'demo3', 'demo4', 'demo5'], form);
4950
const more = Form.useWatch(['age', 'name', 'gender'], form);
50-
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);
5152
return (
5253
<>
5354
<Form

src/useWatch.ts

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ function useWatch<TDependencies extends keyof GetGeneric<TForm>, TForm extends F
4343
form?: TForm,
4444
): GetGeneric<TForm>[TDependencies];
4545

46+
function useWatch<TForm extends FormInstance>(dependencies: [], form?: TForm): GetGeneric<TForm>;
47+
4648
function useWatch<TForm extends FormInstance>(dependencies: NamePath, form?: TForm): any;
4749

4850
function useWatch<ValueType = Store>(dependencies: NamePath, form?: FormInstance): ValueType;

tests/useWatch.test.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ describe('useWatch', () => {
289289

290290
const Demo = () => {
291291
const [form] = Form.useForm<FieldType>();
292+
const values = Form.useWatch([], form);
292293
const main = Form.useWatch('main', form);
293294
const age = Form.useWatch(['age'], form);
294295
const demo1 = Form.useWatch(['demo1'], form);
@@ -299,7 +300,9 @@ describe('useWatch', () => {
299300
const more = Form.useWatch(['age', 'name', 'gender'], form);
300301
const demo = Form.useWatch<string>(['demo']);
301302

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+
);
303306
};
304307

305308
mount(<Demo />);

0 commit comments

Comments
 (0)