MCPcopy Create free account
hub / github.com/Lobos/react-ui / register

Function register

src/higherOrders/FormItem.js:196–228  ·  view source on GitHub ↗
(ComposedComponent, types=[], options={})

Source from the content-addressed store, hash-verified

194}
195
196export const register = (ComposedComponent, types=[], options={}) => {
197 let newComponent = enhance(ComposedComponent);
198
199 // allow empty type
200 //if (isEmpty(types)) {
201 // console.warn('types must be string or array');
202 // return;
203 //}
204
205 if (!Array.isArray(types)) {
206 types = [types];
207 }
208
209 types.forEach((type) => {
210 if (COMPONENTS.hasOwnProperty(type)) {
211 console.warn(`type ${type} was already existed.`);
212 return;
213 }
214
215 let { valueType, render } = options;
216 if (!valueType) {
217 valueType = ['integer', 'number'].indexOf(type) > -1 ? 'number' : 'string';
218 }
219
220 if (!render) {
221 render = (props) => createElement(newComponent, props);
222 }
223
224 COMPONENTS[type] = { render, valueType, component: ComposedComponent };
225 });
226
227 return newComponent;
228}
229
230export const getValueType = (type) => {
231 let valueType = 'string';

Callers 10

RadioGroup.jsFile · 0.90
Upload.jsFile · 0.90
Checkbox.jsFile · 0.90
Select.jsFile · 0.90
CheckboxGroup.jsFile · 0.90
Textarea.jsFile · 0.90
Input.jsFile · 0.90
Tree.jsFile · 0.90
index.jsFile · 0.90
FetchGroup.jsFile · 0.90

Calls 1

enhanceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…