MCPcopy
hub / github.com/react-component/form / onCollectCommon

Function onCollectCommon

src/createBaseForm.js:103–131  ·  view source on GitHub ↗
(name, action, args)

Source from the content-addressed store, hash-verified

101 },
102
103 onCollectCommon(name, action, args) {
104 const fieldMeta = this.fieldsStore.getFieldMeta(name);
105 if (fieldMeta[action]) {
106 fieldMeta[action](...args);
107 } else if (fieldMeta.originalProps && fieldMeta.originalProps[action]) {
108 fieldMeta.originalProps[action](...args);
109 }
110 const value = fieldMeta.getValueFromEvent
111 ? fieldMeta.getValueFromEvent(...args)
112 : getValueFromEvent(...args);
113 if (onValuesChange && value !== this.fieldsStore.getFieldValue(name)) {
114 const valuesAll = this.fieldsStore.getAllValues();
115 const valuesAllSet = {};
116 valuesAll[name] = value;
117 Object.keys(valuesAll).forEach(key =>
118 set(valuesAllSet, key, valuesAll[key]),
119 );
120 onValuesChange(
121 {
122 [formPropName]: this.getForm(),
123 ...this.props,
124 },
125 set({}, name, value),
126 valuesAllSet,
127 );
128 }
129 const field = this.fieldsStore.getField(name);
130 return { name, field: { ...field, value, touched: true }, fieldMeta };
131 },
132
133 onCollect(name_, action, ...args) {
134 const { name, field, fieldMeta } = this.onCollectCommon(

Callers

nothing calls this directly

Calls 5

getValueFromEventFunction · 0.90
onValuesChangeFunction · 0.85
getFieldMetaMethod · 0.80
getValueFromEventMethod · 0.80
getFieldMethod · 0.80

Tested by

no test coverage detected