From 0b8cc13a0764b533fe80eaaeb00ea03ca8a198bc Mon Sep 17 00:00:00 2001 From: xiaofine1122 <985609093@qq.com> Date: Wed, 8 Apr 2020 08:33:42 -0700 Subject: [PATCH] docs: update tree->draggable demo forEach (#23055) --- components/tree/demo/draggable.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/tree/demo/draggable.md b/components/tree/demo/draggable.md index 2afb9c57dd..a584b111cf 100644 --- a/components/tree/demo/draggable.md +++ b/components/tree/demo/draggable.md @@ -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];