MCPcopy
hub / github.com/preactjs/preact / createVNode

Function createVNode

src/create-element.js:57–81  ·  view source on GitHub ↗
(type, props, key, ref, original)

Source from the content-addressed store, hash-verified

55 * @returns {import('./internal').VNode}
56 */
57export function createVNode(type, props, key, ref, original) {
58 // V8 seems to be better at detecting type shapes if the object is allocated from the same call site
59 // Do not inline into createElement and coerceToVNode!
60 /** @type {import('./internal').VNode} */
61 const vnode = {
62 type,
63 props,
64 key,
65 ref,
66 _children: NULL,
67 _parent: NULL,
68 _depth: 0,
69 _dom: NULL,
70 _component: NULL,
71 constructor: UNDEFINED,
72 _original: original == NULL ? ++vnodeId : original,
73 _index: -1,
74 _flags: 0
75 };
76
77 // Only invoke the vnode hook if this was *not* a direct copy:
78 if (original == NULL && options.vnode != NULL) options.vnode(vnode);
79
80 return vnode;
81}
82
83export function createRef() {
84 return { current: NULL };

Callers 3

cloneElementFunction · 0.90
createElementFunction · 0.70

Calls 1

vnodeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…