-
-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support scoped form instance #660
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #660 +/- ##
==========================================
+ Coverage 99.43% 99.47% +0.03%
==========================================
Files 18 19 +1
Lines 1247 1335 +88
Branches 288 308 +20
==========================================
+ Hits 1240 1328 +88
Misses 7 7 ☔ View full report in Codecov by Sentry. |
8cecf25
to
62c59d7
Compare
src/FormInstanceContext.tsx
Outdated
import * as React from 'react'; | ||
import type { InternalFormInstance } from './interface'; | ||
|
||
const FormInstanceContext = React.createContext<InternalFormInstance | undefined>(undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
能复用 Context 不,List 其实也是加了一个 Scope 理论上来说不用新加一个
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
复用FieldContext的话,会造成一个问题:
在子组件里拿到的FormInstance
不等于最顶层的Form.useForm()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
想了一下,确实可以用FieldContext
传递FormInstance
,已修改 @zombieJ
- add hook Form.useFormInstance - Form.useWatch add param "scoped: true"
62c59d7
to
8607178
Compare
ant-design/ant-design#47328