Skip to content

Commit d16f51b

Browse files
committed
Update Rotator to accept new component prop allowing for specifiying a custom wrapping element
1 parent 4ac589e commit d16f51b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/index.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {Component} from 'react';
1+
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33
import cleanProps from 'clean-react-props';
44

@@ -82,6 +82,7 @@ class Rotator extends Component {
8282
render() {
8383
const {
8484
children,
85+
component,
8586
indicator,
8687
} = this.props;
8788

@@ -106,22 +107,26 @@ class Rotator extends Component {
106107
})
107108
: null;
108109

109-
return (
110-
<div {...cleanProps(this.props)}>
111-
{clonedChildren}
112-
{clonedIndicator}
113-
</div>
110+
return React.createElement(component, {
111+
...cleanProps(this.props)
112+
},
113+
[...clonedChildren, clonedIndicator]
114114
);
115115
}
116116
}
117117

118118
Rotator.propTypes = {
119+
component: PropTypes.oneOfType([
120+
PropTypes.element,
121+
PropTypes.string,
122+
]),
119123
index: PropTypes.number,
120124
indicator: PropTypes.element,
121125
onChange: PropTypes.func,
122126
};
123127

124128
Rotator.defaultProps = {
129+
component: 'div',
125130
index: 0,
126131
onChange: () => {},
127132
};

0 commit comments

Comments
 (0)