Skip to content

Commit

Permalink
Filter out null children (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
davvidbaker authored and wuweiweiwu committed Jul 27, 2018
1 parent 032e47b commit ec8d4ae
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/SplitPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -292,6 +295,8 @@ class SplitPane extends React.Component {
? `${resizerClassName} ${RESIZER_DEFAULT_CLASSNAME}`
: resizerClassName;

const notNullChildren = removeNullChildren(children);

const style = Object.assign(
{},
{
Expand Down Expand Up @@ -354,7 +359,7 @@ class SplitPane extends React.Component {
split={split}
style={pane1Style}
>
{children[0]}
{notNullChildren[0]}
</Pane>
<Resizer
className={disabledClass}
Expand All @@ -378,7 +383,7 @@ class SplitPane extends React.Component {
split={split}
style={pane2Style}
>
{children[1]}
{notNullChildren[1]}
</Pane>
</div>
);
Expand Down

2 comments on commit ec8d4ae

@davvidbaker
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wuweiweiwu hey any chance we could get this into the npm package?

@wuweiweiwu
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I will try to release soon!

Please sign in to comment.