From 08912c07d99d2b1ca40c9437bf5d142a9b5f6674 Mon Sep 17 00:00:00 2001 From: xuejr <ლ(`∀´ლ)> Date: Mon, 6 Apr 2020 12:12:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0mapChildren?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/react/ReactChildren.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/react/ReactChildren.js b/src/react/ReactChildren.js index bbc07d8..f941328 100644 --- a/src/react/ReactChildren.js +++ b/src/react/ReactChildren.js @@ -1,6 +1,10 @@ function mapChildren(children, func, context) { //TODO实现此mapChildren方法 - return children; + const isArray = Array.isArray(children) + if (!isArray) { + return func(children, 0) + } + return children.flat(Infinity).map(func) } export { -- Gitee