Skip to content

Commit 3f2da66

Browse files
authored
Refactor victory-accessible-group to a function component (#2777)
1 parent d8be277 commit 3f2da66

File tree

2 files changed

+35
-33
lines changed

2 files changed

+35
-33
lines changed

.changeset/eleven-dogs-laugh.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"victory-core": patch
3+
---
4+
5+
Refactor victory-accessible-group to a function component

packages/victory-core/src/victory-accessible-group/victory-accessible-group.tsx

+30-33
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,34 @@ export interface VictoryAccessibleGroupProps {
99
tabIndex?: number;
1010
}
1111

12-
export class VictoryAccessibleGroup extends React.Component<VictoryAccessibleGroupProps> {
13-
static displayName = "VictoryAccessibleGroup";
12+
export const VictoryAccessibleGroup = ({
13+
desc,
14+
children,
15+
tabIndex,
16+
className = "VictoryAccessibleGroup",
17+
...props
18+
}: VictoryAccessibleGroupProps) => {
19+
const descId =
20+
desc && (props["aria-describedby"] || desc.split(" ").join("-"));
1421

15-
static defaultProps = {
16-
className: "VictoryAccessibleGroup",
17-
};
18-
19-
render() {
20-
const { desc, children, className, tabIndex } = this.props;
21-
const descId =
22-
desc && (this.props["aria-describedby"] || desc.split(" ").join("-"));
23-
24-
return desc ? (
25-
<g
26-
aria-label={this.props["aria-label"]}
27-
aria-describedby={descId}
28-
className={className}
29-
tabIndex={tabIndex}
30-
>
31-
<desc id={descId}>{desc}</desc>
32-
{children}
33-
</g>
34-
) : (
35-
<g
36-
aria-label={this.props["aria-label"]}
37-
aria-describedby={this.props["aria-describedby"]}
38-
className={className}
39-
tabIndex={tabIndex}
40-
>
41-
{children}
42-
</g>
43-
);
44-
}
45-
}
22+
return desc ? (
23+
<g
24+
aria-label={props["aria-label"]}
25+
aria-describedby={descId}
26+
className={className}
27+
tabIndex={tabIndex}
28+
>
29+
<desc id={descId}>{desc}</desc>
30+
{children}
31+
</g>
32+
) : (
33+
<g
34+
aria-label={props["aria-label"]}
35+
aria-describedby={props["aria-describedby"]}
36+
className={className}
37+
tabIndex={tabIndex}
38+
>
39+
{children}
40+
</g>
41+
);
42+
};

0 commit comments

Comments
 (0)