Skip to content

Commit 0f225ce

Browse files
committed
Lint & Modernize Label.jsx
1 parent 9bee480 commit 0f225ce

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"no-restricted-globals": ["warn"],
1414
"react/button-has-type": ["warn"],
1515
"react/prop-types": ["warn"],
16-
"jsx-a11y/heading-has-content": ["warn"]
16+
"jsx-a11y/heading-has-content": ["warn"],
17+
"jsx-a11y/control-has-associated-label": ["warn"]
1718
},
1819
"env": {
1920
"browser": true,
Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
1-
import React from 'react';
1+
import React from "react";
22
import { connect } from "react-redux";
33
import { removeLabel } from "../redux/actions";
44

5-
class Label extends React.Component {
6-
constructor(props) {
7-
super(props);
8-
}
5+
function Label(props) {
6+
const { label, removeLabel } = props;
97

10-
removeLabel = () => {
11-
this.props.removeLabel(this.props.label.name);
12-
};
13-
14-
render() {
15-
return <div className="label">
16-
<span className="label-name">{this.props.label.name}</span>
17-
<span className="label-value">{this.props.label.value}</span>
18-
<button className="label-delete-btn" onClick={this.removeLabel}></button>
8+
return (
9+
<div className="label">
10+
<span className="label-name">{label.name}</span>
11+
<span className="label-value">{label.value}</span>
12+
<button
13+
className="label-delete-btn"
14+
onClick={() => removeLabel(label.name)}
15+
/>
1916
</div>
20-
}
17+
);
2118
}
2219

23-
export default connect(
24-
(x) => x,
25-
{ removeLabel }
26-
)(Label);
20+
export default connect((x) => x, { removeLabel })(Label);

0 commit comments

Comments
 (0)