Gathering detailed insights and metrics for rc-field-form
Gathering detailed insights and metrics for rc-field-form
Gathering detailed insights and metrics for rc-field-form
Gathering detailed insights and metrics for rc-field-form
dw-neit-rc-field-form
React Form Component
blake-field-form
对antd V4 版本的Form表单进行的模仿封装,底层引用 rc-field-form
@jeff_drumgod/rc-field-form
React Form Component - With React 18 support
@redshank/reactivity-hook-form
Reactivity Hook Form is an innovative wrapper designed to work with React Hook Form, a popular library for managing forms in React. This wrapper focuses on simplifying and automating the process of form integration, providing an elegant and efficient solu
npm install rc-field-form
Typescript
Module System
Min. Node Version
Node Version
NPM Version
92.6
Supply Chain
94.6
Quality
85.5
Maintenance
100
Vulnerability
100
License
@rc-component/form@1.2.0
Updated on Jun 27, 2025
@rc-component/form@1.1.0
Updated on Jan 22, 2025
@rc-component/form@1.0.0
Updated on Jan 21, 2025
v2.7.0
Updated on Dec 12, 2024
v2.6.0
Updated on Nov 27, 2024
v2.5.1
Updated on Nov 13, 2024
TypeScript (99.76%)
JavaScript (0.24%)
Total Downloads
213,393,439
Last Day
70,895
Last Week
1,577,864
Last Month
6,744,737
Last Year
71,484,213
MIT License
1,014 Stars
446 Commits
276 Forks
11 Watchers
19 Branches
59 Contributors
Updated on Jun 27, 2025
Minified
Minified + Gzipped
Latest Version
2.7.0
Package Id
rc-field-form@2.7.0
Unpacked Size
285.13 kB
Size
46.31 kB
File Count
75
NPM Version
10.8.2
Node Version
22.5.1
Published on
Dec 12, 2024
Cumulative downloads
Total Downloads
Last Day
3.3%
70,895
Compared to previous day
Last Week
-12.8%
1,577,864
Compared to previous week
Last Month
1.7%
6,744,737
Compared to previous month
Last Year
30.7%
71,484,213
Compared to previous year
3
26
React Performance First Form Component.
1npm install 2npm start 3open http://localhost:8000
1import Form, { Field } from 'rc-field-form'; 2 3const Input = ({ value = '', ...props }) => <input value={value} {...props} />; 4 5const Demo = () => { 6 return ( 7 <Form 8 onFinish={values => { 9 console.log('Finish:', values); 10 }} 11 > 12 <Field name="username"> 13 <Input placeholder="Username" /> 14 </Field> 15 <Field name="password"> 16 <Input placeholder="Password" /> 17 </Field> 18 19 <button>Submit</button> 20 </Form> 21 ); 22}; 23 24export default Demo;
We use typescript to create the Type definition. You can view directly in IDE. But you can still check the type definition here.
Prop | Description | Type | Default |
---|---|---|---|
component | Customize Form render component | string | Component | false | form |
fields | Control Form fields status. Only use when in Redux | FieldData[] | - |
form | Set form instance created by useForm | FormInstance | Form.useForm() |
initialValues | Initial value of Form | Object | - |
name | Config name with FormProvider | string | - |
preserve | Preserve value when field removed | boolean | false |
validateMessages | Set validate message template | ValidateMessages | - |
onFieldsChange | Trigger when any value of Field changed | (changedFields, allFields) => void | - |
onFinish | Trigger when form submit and success | (values) => void | - |
onFinishFailed | Trigger when form submit and failed | ({ values, errorFields, outOfDate }) => void | - |
onValuesChange | Trigger when any value of Field changed | (changedValues, values) => void | - |
Prop | Description | Type | Default |
---|---|---|---|
dependencies | Will re-render if dependencies changed | NamePath[] | - |
getValueFromEvent | Specify how to get value from event | (..args: any[]) => any | - |
getValueProps | Customize additional props with value. This prop will disable valuePropName | (value) => any | - |
initialValue | Field initial value | any | - |
name | Field name path | NamePath | - |
normalize | Normalize value before update | (value, prevValue, prevValues) => any | - |
preserve | Preserve value when field removed | boolean | false |
rules | Validate rules | Rule[] | - |
shouldUpdate | Check if Field should update | boolean | (prevValues, nextValues) => boolean | - |
trigger | Collect value update by event trigger | string | onChange |
validateTrigger | Config trigger point with rule validate | string | string[] | onChange |
valuePropName | Config value mapping prop with element | string | value |
Prop | Description | Type | Default |
---|---|---|---|
name | List field name path | NamePath[] | - |
children | Render props for listing fields | (fields: { name: NamePath }[], operations: ListOperations) => ReactNode | - |
Form component default create an form instance by Form.useForm
. But you can create it and pass to Form also. This allow you to call some function on the form instance.
1const Demo = () => { 2 const [form] = Form.useForm(); 3 return <Form form={form} />; 4};
For class component user, you can use ref
to get form instance:
1class Demo extends React.Component { 2 setRef = form => { 3 // Form instance here 4 }; 5 6 render() { 7 return <Form ref={this.setRef} />; 8 } 9}
Prop | Description | Type |
---|---|---|
getFieldValue | Get field value by name path | (name: NamePath) => any |
getFieldsValue | Get list of field values by name path list | (nameList?: (NamePath[]) => any) | true |
getFieldError | Get field errors by name path | (name: NamePath) => string[] |
getFieldsError | Get list of field errors by name path list | (nameList?: NamePath[]) => FieldError[] |
isFieldsTouched | Check if list of fields are touched | (nameList?: NamePath[], allTouched?: boolean) => boolean |
isFieldTouched | Check if a field is touched | (name: NamePath) => boolean |
isFieldValidating | Check if a field is validating | (name: NamePath) => boolean |
resetFields | Reset fields status | (fields?: NamePath[]) => void |
setFields | Set fields status | (fields: FieldData[]) => void |
setFieldsValue | Set fields value | (values) => void |
submit | Trigger form submit | () => void |
validateFields | Trigger fields to validate | (nameList?: NamePath[], options?: ValidateOptions) => Promise |
Prop | Description | Type | Default |
---|---|---|---|
validateMessages | Config global validateMessages template | ValidateMessages | - |
onFormChange | Trigger by named form fields change | (name, { changedFields, forms }) => void | - |
onFormFinish | Trigger by named form fields finish | (name, { values, forms }) => void | - |
Type |
---|
string | number | (string | number)[] |
Prop | Type |
---|---|
touched | boolean |
validating | boolean |
errors | string[] |
name | string | number | (string | number)[] |
value | any |
Prop | Type |
---|---|
enum | any[] |
len | number |
max | number |
message | string |
min | number |
pattern | RegExp |
required | boolean |
transform | (value) => any |
type | string |
validator | (rule, value, callback: (error?: string) => void, form) => Promise | void |
whitespace | boolean |
validateTrigger | string | string[] |
To keep sync with rc-form
legacy usage of validator
, we still provides callback
to trigger validate finished. But in rc-field-form
, we strongly recommend to return a Promise instead.
Prop | Type |
---|---|
add | (initValue: any) => void |
remove | (index: number) => void |
Validate Messages provides a list of error template. You can ref here for fully default templates.
Prop | Description |
---|---|
enum | Rule enum prop |
len | Rule len prop |
max | Rule max prop |
min | Rule min prop |
name | Field name |
pattern | Rule pattern prop |
type | Rule type prop |
rc-form
rc-field-form
is try to keep sync with rc-form
in api level, but there still have something to change:
initialValues
when un-touchedIn rc-form
, field value will get from initialValues
if user not operate on it.
It's a bug but user use as a feature which makes fixing will be a breaking change and we have to keep it.
In Field Form, this bug will not exist anymore. If you want to change a field value, use setFieldsValue
instead.
We do lots of logic to clean up the value when Field removed before. But with user feedback, remove exist value increase the additional work to keep value back with conditional field.
In rc-form
, we support like user.name
to be a name and convert value to { user: { name: 'Bamboo' } }
. This makes '.' always be the route of variable, this makes developer have to do additional work if name is real contains a point like app.config.start
to be app_config_start
and parse back to point when submit.
Field Form will only trade ['user', 'name']
to be { user: { name: 'Bamboo' } }
, and user.name
to be { ['user.name']: 'Bamboo' }
.
validateFieldsAndScroll
Since findDomNode
is marked as warning in StrictMode. It seems over control of Form component.
We decide to remove validateFieldsAndScroll
method and you should handle it with you own logic:
1<Form> 2 <Field name="username"> 3 <input ref={this.inputRef} /> 4 </Field> 5</Form>
getFieldsError
always return arrayrc-form
returns null
when no error happen. This makes user have to do some additional code like:
1(form.getFieldsError('fieldName') || []).forEach(() => { 2 // Do something... 3});
Now getFieldsError
will return []
if no errors.
callback
with validateFields
Since ES8 is support async/await
, that's no reason not to use it. Now you can easily handle your validate logic:
1async function() { 2 try { 3 const values = await form.validateFields(); 4 console.log(values); 5 } catch (errorList) { 6 errorList.forEach(({ name, errors }) => { 7 // Do something... 8 }); 9 } 10}
Notice: Now if your validator return an Error(message)
, not need to get error by e => e.message
. FieldForm will handle this.
preserve
is default to falseIn rc-form
you should use preserve
to keep a value cause Form will auto remove a value from Field removed. Field Form will always keep the value in the Form whatever Field removed. But you can still use preserve=false
to disable value keeping since 1.5.0
.
setFields
not trigger onFieldsChange
and setFieldsValue
not trigger onValuesChange
In rc-form
, we hope to help user auto trigger change event by setting to make redux dispatch easier, but it's not good design since it makes code logic couping.
Additionally, user control update trigger onFieldsChange
& onValuesChange
event has potential dead loop risk.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 6
Details
Reason
Found 9/25 approved changesets -- score normalized to 3
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More