Skip to content

Commit

Permalink
Fix: Use React.Children.toArray instead of manual conversion (#4)
Browse files Browse the repository at this point in the history
Close #3
  • Loading branch information
Mikhail Bashurov authored and sapegin committed Apr 9, 2018
1 parent b5e22ea commit f4198a8
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
var React = require('react');
var PropTypes = require('prop-types');

function castArray(value) {
return Array.isArray(value) ? value : [value];
}

/**
* React component to render collection of items separated by space or other separator.
*/
function Group(props) {
// Accept multiple children, one child or none
var children = props.children ? castArray(props.children) : [];

// Skip falsy children
children = children.filter(function(child) {
return !!child;
});
var children = React.Children.toArray(props.children);

// Insert separators
var items = children;
Expand Down

0 comments on commit f4198a8

Please sign in to comment.