File tree 1 file changed +15
-20
lines changed
1 file changed +15
-20
lines changed Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
- import DisplayName from '../helpers/DisplayName' ;
3
2
import { DivAttributes } from '../helpers/types' ;
4
3
import { assertValidHtmlId } from '../helpers/uuid' ;
5
4
import { Consumer as ItemConsumer , ItemContext } from './ItemContext' ;
6
5
7
- type Props = DivAttributes ;
6
+ type Props = DivAttributes & { className ?: string } ;
8
7
9
- const defaultProps = {
10
- className : 'accordion__panel' ,
11
- } ;
12
-
13
- export default class AccordionItemPanel extends React . Component < Props > {
14
- static defaultProps : typeof defaultProps = defaultProps ;
15
-
16
- static displayName : DisplayName . AccordionItemPanel =
17
- DisplayName . AccordionItemPanel ;
18
-
19
- renderChildren = ( { panelAttributes } : ItemContext ) : JSX . Element => {
20
- if ( this . props . id ) {
21
- assertValidHtmlId ( this . props . id ) ;
8
+ const AccordionItemPanel = ( {
9
+ className = 'accordion__panel' ,
10
+ id,
11
+ ...rest
12
+ } : Props ) => {
13
+ const renderChildren = ( { panelAttributes } : ItemContext ) : JSX . Element => {
14
+ if ( id ) {
15
+ assertValidHtmlId ( id ) ;
22
16
}
23
17
24
18
return (
25
19
< div
26
20
data-accordion-component = "AccordionItemPanel"
27
- { ...this . props }
21
+ className = { className }
22
+ { ...rest }
28
23
{ ...panelAttributes }
29
24
/>
30
25
) ;
31
26
} ;
32
27
33
- render ( ) : JSX . Element {
34
- return < ItemConsumer > { this . renderChildren } </ ItemConsumer > ;
35
- }
36
- }
28
+ return < ItemConsumer > { renderChildren } </ ItemConsumer > ;
29
+ } ;
30
+
31
+ export default AccordionItemPanel ;
You can’t perform that action at this time.
0 commit comments