MCPcopy Create free account
hub / github.com/BetaSu/big-react / createElement

Function createElement

packages/react/src/jsx.ts:38–74  ·  view source on GitHub ↗
(
	type: ElementType,
	config: any,
	...maybeChildren: any
)

Source from the content-addressed store, hash-verified

36}
37
38export const createElement = (
39 type: ElementType,
40 config: any,
41 ...maybeChildren: any
42) => {
43 let key: Key = null;
44 const props: Props = {};
45 let ref: Ref = null;
46
47 for (const prop in config) {
48 const val = config[prop];
49 if (prop === 'key') {
50 if (val !== undefined) {
51 key = '' + val;
52 }
53 continue;
54 }
55 if (prop === 'ref') {
56 if (val !== undefined) {
57 ref = val;
58 }
59 continue;
60 }
61 if ({}.hasOwnProperty.call(config, prop)) {
62 props[prop] = val;
63 }
64 }
65 const maybeChildrenLength = maybeChildren.length;
66 if (maybeChildrenLength) {
67 if (maybeChildrenLength === 1) {
68 props.children = maybeChildren[0];
69 } else {
70 props.children = maybeChildren;
71 }
72 }
73 return ReactElement(type, key, ref, props);
74};
75
76export const Fragment = REACT_FRAGMENT_TYPE;
77

Callers

nothing calls this directly

Calls 1

ReactElementFunction · 0.85

Tested by

no test coverage detected