From 10a006be353bfc4ad59435ff59870ef2c9743bd8 Mon Sep 17 00:00:00 2001
From: crazyair <645381995@qq.com>
Date: Sun, 22 Jun 2025 19:30:11 +0800
Subject: [PATCH 1/5] feat: test
---
docs/examples/basic.tsx | 74 ++++++++++++++++++-----------------------
src/interface.ts | 6 +---
src/useForm.ts | 17 +++++-----
3 files changed, 43 insertions(+), 54 deletions(-)
diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx
index 48a46fc14..61672fb6b 100644
--- a/docs/examples/basic.tsx
+++ b/docs/examples/basic.tsx
@@ -1,51 +1,43 @@
-import Form, { Field } from 'rc-field-form';
import React from 'react';
-import Input from './components/Input';
+import get from 'lodash/get';
-type FormData = {
- name?: string;
- password?: string;
- password2?: string;
-};
+import Form, { Field } from 'rc-field-form';
+import Input from './components/Input';
-export default () => {
- const [form] = Form.useForm();
+const Child = ({ name, remove }: { name: any; remove: () => void }) => {
+ // console.log('22', name);
+ const nameValue = Form.useWatch(values => {
+ console.log('name', name);
+ return get(values, ['list', name, 'name']);
+ });
+ // const nameValue2 = Form.useWatch(['list', name, 'name']);
return (
-
);
};
+
+export default Demo;
diff --git a/src/interface.ts b/src/interface.ts
index 482f6d098..78b77c6c3 100644
--- a/src/interface.ts
+++ b/src/interface.ts
@@ -209,11 +209,7 @@ export interface Callbacks {
onFinishFailed?: (errorInfo: ValidateErrorEntity) => void;
}
-export type WatchCallBack = (
- values: Store,
- allValues: Store,
- namePathList: InternalNamePath[],
-) => void;
+export type WatchCallBack = (values: Store, allValues: Store) => void;
export interface WatchOptions
+ {(fields, { remove }) => (
+
+ {fields.map(field => (
+ remove(field.name)} />
+ ))}
+
+ )}
+
+
+ );
+};
+
+export default Demo;
diff --git a/src/useForm.ts b/src/useForm.ts
index c14021d03..11bdb79c8 100644
--- a/src/useForm.ts
+++ b/src/useForm.ts
@@ -681,6 +681,7 @@ export class FormStore {
this.triggerDependenciesUpdate(prevStore, namePath);
}
}
+
this.notifyWatch();
};
};
diff --git a/src/useWatch.ts b/src/useWatch.ts
index 18e29218a..7446f2316 100644
--- a/src/useWatch.ts
+++ b/src/useWatch.ts
@@ -128,7 +128,6 @@ function useWatch(
namePathRef.current = namePath;
useWatchWarning(namePath);
- console.log('valueStr', valueStr);
useEffect(
() => {
// Skip if not exist form instance
From 20a37a8f28b16b6b85316bf91bae4bb6ca10c803 Mon Sep 17 00:00:00 2001
From: crazyair <645381995@qq.com>
Date: Sun, 22 Jun 2025 20:56:59 +0800
Subject: [PATCH 4/5] feat: test
---
docs/examples/basic.tsx | 71 +++++++++++++++++++++++------------------
1 file changed, 40 insertions(+), 31 deletions(-)
diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx
index b371512c2..48a46fc14 100644
--- a/docs/examples/basic.tsx
+++ b/docs/examples/basic.tsx
@@ -1,42 +1,51 @@
-import React from 'react';
-import get from 'lodash/get';
-
import Form, { Field } from 'rc-field-form';
+import React from 'react';
import Input from './components/Input';
-const Child = ({ name, remove }: { name: any; remove: () => void }) => {
- const nameValue = Form.useWatch(values => {
- return get(values, ['list', name, 'name']);
- });
+type FormData = {
+ name?: string;
+ password?: string;
+ password2?: string;
+};
+
+export default () => {
+ const [form] = Form.useForm();
return (
-
- );
-};
-const Demo = () => {
- return (
-
- {(fields, { remove }) => (
-
- {fields.map(field => (
- remove(field.name)} />
- ))}
-
- )}
-
+
);
};
-
-export default Demo;
From 3288f64d2299d98ff23b95e1b96f2f3f88ac4399 Mon Sep 17 00:00:00 2001
From: crazyair <645381995@qq.com>
Date: Sun, 22 Jun 2025 20:57:46 +0800
Subject: [PATCH 5/5] feat: test
---
docs/demo/useWatch-list-level2.md | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 docs/demo/useWatch-list-level2.md
diff --git a/docs/demo/useWatch-list-level2.md b/docs/demo/useWatch-list-level2.md
new file mode 100644
index 000000000..6852825d3
--- /dev/null
+++ b/docs/demo/useWatch-list-level2.md
@@ -0,0 +1,3 @@
+## useWatch-list-level2
+
+