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

Function createBaseForm

src/createBaseForm.js:29–722  ·  view source on GitHub ↗
(option = {}, mixins = [])

Source from the content-addressed store, hash-verified

27const DEFAULT_TRIGGER = 'onChange';
28
29function createBaseForm(option = {}, mixins = []) {
30 const {
31 validateMessages,
32 onFieldsChange,
33 onValuesChange,
34 mapProps = identity,
35 mapPropsToFields,
36 fieldNameProp,
37 fieldMetaProp,
38 fieldDataProp,
39 formPropName = 'form',
40 name: formName,
41 // @deprecated
42 withRef,
43 } = option;
44
45 return function decorate(WrappedComponent) {
46 const Form = createReactClass({
47 mixins,
48
49 getInitialState() {
50 const fields = mapPropsToFields && mapPropsToFields(this.props);
51 this.fieldsStore = createFieldsStore(fields || {});
52
53 this.instances = {};
54 this.cachedBind = {};
55 this.clearedFieldMetaCache = {};
56
57 this.renderFields = {};
58 this.domFields = {};
59
60 // HACK: https://github.com/ant-design/ant-design/issues/6406
61 [
62 'getFieldsValue',
63 'getFieldValue',
64 'setFieldsInitialValue',
65 'getFieldsError',
66 'getFieldError',
67 'isFieldValidating',
68 'isFieldsValidating',
69 'isFieldsTouched',
70 'isFieldTouched',
71 ].forEach(key => {
72 this[key] = (...args) => {
73 if (process.env.NODE_ENV !== 'production') {
74 warning(
75 false,
76 'you should not use `ref` on enhanced form, please use `wrappedComponentRef`. ' +
77 'See: https://github.com/react-component/form#note-use-wrappedcomponentref-instead-of-withref-after-rc-form140',
78 );
79 }
80 return this.fieldsStore[key](...args);
81 };
82 });
83
84 return {
85 submitting: false,
86 };

Callers 2

createFormFunction · 0.85
createDOMFormFunction · 0.85

Calls 1

argumentContainerFunction · 0.90

Tested by

no test coverage detected