From f97b826f9c0744ddb463fdbe94447f10fdc145d3 Mon Sep 17 00:00:00 2001 From: Viktor Andersson <30777521+VIKTORVAV99@users.noreply.github.com> Date: Mon, 15 Jul 2024 17:58:11 +0200 Subject: [PATCH] Simplifies hasValidReactChildren --- src/TransWithoutContext.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/TransWithoutContext.js b/src/TransWithoutContext.js index f6d00f10..37b51084 100644 --- a/src/TransWithoutContext.js +++ b/src/TransWithoutContext.js @@ -17,10 +17,8 @@ const getChildren = (node) => { return node.props && node.props.i18nIsDynamicList ? getAsArray(children) : children; }; -const hasValidReactChildren = (children) => { - if (Object.prototype.toString.call(children) !== '[object Array]') return false; - return children.every((child) => isValidElement(child)); -}; +const hasValidReactChildren = (children) => + Array.isArray(children) && children.every(isValidElement); const getAsArray = (data) => (Array.isArray(data) ? data : [data]);