@@ -6,15 +6,16 @@ import { Transition } from 'react-transition-group';
6
6
import { useBootstrapPrefix } from './ThemeProvider' ;
7
7
import Collapse , { CollapseProps } from './Collapse' ;
8
8
import AccordionContext from './AccordionContext' ;
9
- import { BsPrefixRefForwardingComponent , BsPrefixOnlyProps } from './helpers' ;
9
+ import { BsPrefixRefForwardingComponent , BsPrefixProps } from './helpers' ;
10
10
11
- export interface AccordionCollapseProps
12
- extends BsPrefixOnlyProps ,
13
- CollapseProps {
11
+ export interface AccordionCollapseProps extends BsPrefixProps , CollapseProps {
14
12
eventKey : string ;
15
13
}
16
14
17
15
const propTypes = {
16
+ /** Set a custom element for this component */
17
+ as : PropTypes . elementType ,
18
+
18
19
/**
19
20
* A key that corresponds to the toggler that triggers this collapse's expand or collapse.
20
21
*/
@@ -28,7 +29,17 @@ const AccordionCollapse: BsPrefixRefForwardingComponent<
28
29
'div' ,
29
30
AccordionCollapseProps
30
31
> = React . forwardRef < Transition < any > , AccordionCollapseProps > (
31
- ( { bsPrefix, className, children, eventKey, ...props } , ref ) => {
32
+ (
33
+ {
34
+ as : Component = 'div' ,
35
+ bsPrefix,
36
+ className,
37
+ children,
38
+ eventKey,
39
+ ...props
40
+ } ,
41
+ ref ,
42
+ ) => {
32
43
const { activeEventKey } = useContext ( AccordionContext ) ;
33
44
bsPrefix = useBootstrapPrefix ( bsPrefix , 'accordion-collapse' ) ;
34
45
@@ -39,7 +50,7 @@ const AccordionCollapse: BsPrefixRefForwardingComponent<
39
50
{ ...props }
40
51
className = { classNames ( className , bsPrefix ) }
41
52
>
42
- < div > { React . Children . only ( children ) } </ div >
53
+ < Component > { React . Children . only ( children ) } </ Component >
43
54
</ Collapse >
44
55
) ;
45
56
} ,
0 commit comments