From e688970a9daef05ec6a83aad0209590a6ee576a3 Mon Sep 17 00:00:00 2001 From: davvidbaker Date: Thu, 26 Jul 2018 10:50:45 -0600 Subject: [PATCH] don't break when a child is null --- src/SplitPane.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/SplitPane.js b/src/SplitPane.js index feb44a9d..7add08e1 100644 --- a/src/SplitPane.js +++ b/src/SplitPane.js @@ -36,6 +36,9 @@ function getDefaultSize(defaultSize, minSize, maxSize, draggedSize) { return minSize; } +function removeNullChildren(children) { + return React.Children.toArray(children).filter(c => c); +} class SplitPane extends React.Component { constructor(props) { super(props); @@ -292,6 +295,8 @@ class SplitPane extends React.Component { ? `${resizerClassName} ${RESIZER_DEFAULT_CLASSNAME}` : resizerClassName; + const notNullChildren = removeNullChildren(children); + const style = Object.assign( {}, { @@ -354,7 +359,7 @@ class SplitPane extends React.Component { split={split} style={pane1Style} > - {children[0]} + {notNullChildren[0]} - {children[1]} + {notNullChildren[1]} );