Skip to content

Commit

Permalink
Duck typing for Columns in Row
Browse files Browse the repository at this point in the history
  • Loading branch information
makarenya committed Nov 15, 2019
1 parent 18a3580 commit 146135d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"rules": {
"react/boolean-prop-naming": "off",
"react/forbid-component-props": "off",
"unicorn/filename-case": "off"
"unicorn/filename-case": "off",
"no-new-object": "off"
},
"parser": "babel-eslint"
},
Expand Down
3 changes: 1 addition & 2 deletions src/components/Row.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {Children, cloneElement} from 'react';
import PropTypes from 'prop-types';
import getAttrs from '../util/getAttrs';
import Column from './Column';

/**
* Grid row. Use this to define a grid containing a set of columns.
Expand All @@ -20,7 +19,7 @@ export default function Row(props) {
<tbody>
{/* `first` and `last` props are added to the first and last child in the row, respectively */}
<tr>{Children.map(props.children, (child, index) => {
if (child.type === Column) {
if ('props' in new Object(child) && 'first' in child.props && 'last' in child.props) {
return cloneElement(child, {
first: index === 0,
last: index === Children.count(props.children) - 1
Expand Down

0 comments on commit 146135d

Please sign in to comment.