MCPcopy Create free account
hub / github.com/nodegui/react-nodegui / appendChild

Method appendChild

src/components/GridView/RNGridView.ts:111–146  ·  view source on GitHub ↗
(child: RNGridRow)

Source from the content-addressed store, hash-verified

109 this.appendChild(child);
110 }
111 appendChild(child: RNGridRow): void {
112 if (!(child instanceof RNGridRow)) {
113 throw new Error("GridRow is the only supported child of GridView");
114 }
115
116 const updateChild = () => {
117 const offset = offsetForIndex<RNGridRow>(
118 this.childRows.length,
119 this.childRows,
120 "height"
121 );
122
123 child.setParentGridAndUpdateProps(this, offset);
124
125 this.childRows.push({
126 offset,
127 data: child,
128 });
129 };
130
131 if (this.layout()) {
132 updateChild();
133
134 return;
135 }
136
137 const layout = new QGridLayout();
138 this.setLayout(layout);
139
140 // Newly created layout, so set initial props
141 if (this.initialProps) {
142 setGridViewProps(this, this.initialProps, {});
143 }
144
145 updateChild();
146 }
147 insertBefore(child: RNGridRow, beforeChild: RNGridRow): void {
148 const prevIndex = this.childRows.findIndex(
149 ({ data }) => data === beforeChild

Callers 1

appendInitialChildMethod · 0.95

Calls 3

layoutMethod · 0.95
setLayoutMethod · 0.95
setGridViewPropsFunction · 0.85

Tested by

no test coverage detected