MCPcopy Create free account
hub / github.com/ElemeFE/element-react / updateChildren

Method updateChildren

src/tree/model/node.js:312–336  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

310 }
311
312 updateChildren() {
313 const newData = this.getChildren() || [];
314 const oldData = this.childNodes.map((node) => node.data);
315
316 const newDataMap = {};
317 const newNodes = [];
318
319 newData.forEach((item, index) => {
320 if (item[NODE_KEY]) {
321 newDataMap[item[NODE_KEY]] = { index, data: item };
322 } else {
323 newNodes.push({ index, data: item });
324 }
325 });
326
327 oldData.forEach((item) => {
328 if (!newDataMap[item[NODE_KEY]]) this.removeChildByData(item);
329 });
330
331 newNodes.forEach(({ index, data }) => {
332 this.insertChild({ data }, index);
333 });
334
335 this.updateLeafState();
336 }
337
338 loadData(callback, defaultProps = {}) {
339 if (this.store.lazy === true && this.store.load && !this.loaded && !this.loading) {

Callers 1

componentDidMountMethod · 0.80

Calls 4

getChildrenMethod · 0.95
removeChildByDataMethod · 0.95
insertChildMethod · 0.95
updateLeafStateMethod · 0.95

Tested by

no test coverage detected