docs: update tree->draggable demo forEach (#23055)

This commit is contained in:
xiaofine1122 2020-04-08 08:33:42 -07:00 committed by GitHub
parent cde4c1a749
commit 0b8cc13a07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,14 +66,14 @@ class Demo extends React.Component {
const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]);
const loop = (data, key, callback) => {
data.forEach((item, index, arr) => {
if (item.key === key) {
return callback(item, index, arr);
for (let i = 0; i < data.length; i++) {
if (data[i].key === key) {
return callback(data[i], i, data);
}
if (item.children) {
return loop(item.children, key, callback);
if (data[i].children) {
loop(data[i].children, key, callback);
}
});
}
};
const data = [...this.state.gData];