Skip to content

Commit

Permalink
Remove slightly unnecessary <span> tag
Browse files Browse the repository at this point in the history
  • Loading branch information
jakezatecky committed May 8, 2018
1 parent e83c8d1 commit aa68b3f
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions src/js/TreeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,34 +197,37 @@ class TreeNode extends React.Component {
const clickable = onClick.toString() !== TreeNode.defaultProps.onClick.toString();
const inputId = `${treeId}-${value.split(' ').join('_')}`;

return (
<span>

This comment has been minimized.

Copy link
@yp

yp May 10, 2018

Replacing the <span> element with an array triggers the warning Each child in an array or iterator should have a unique "key" prop.. Do you mind to add the key attribute (or to revert the commit)? Thanks.

This comment has been minimized.

Copy link
@jakezatecky

jakezatecky May 10, 2018

Author Owner

I can see this warning does appear when running the tests, but I did not notice it a couple days ago. It does not help that the warning did not stop anything in Travis CI, so I was further unawares. Annoying.

I pushed a fix and published a new npm version that gets rid of the warning.

<label htmlFor={inputId}>
<NativeCheckbox
checked={checked === 1}
disabled={disabled}
id={inputId}
indeterminate={checked === 2}
onChange={this.onCheck}
/>
<span className="rct-checkbox">
{this.renderCheckboxIcon()}
</span>
{!clickable ? children : null}
</label>
{clickable ? (
<span
className="rct-node-clickable"
onClick={this.onClick}
onKeyPress={this.onClick}
role="link"
tabIndex={0}
>
{children}
</span>
) : null}
</span>
);
const render = [(
<label htmlFor={inputId}>
<NativeCheckbox
checked={checked === 1}
disabled={disabled}
id={inputId}
indeterminate={checked === 2}
onChange={this.onCheck}
/>
<span className="rct-checkbox">
{this.renderCheckboxIcon()}
</span>
{!clickable ? children : null}
</label>
)];

if (clickable) {
render.push((
<span
className="rct-node-clickable"
onClick={this.onClick}
onKeyPress={this.onClick}
role="link"
tabIndex={0}
>
{children}
</span>
));
}

return render;
}

renderLabel() {
Expand Down

0 comments on commit aa68b3f

Please sign in to comment.