Skip to content

Commit f1df71d

Browse files
committed
Update component to allow for component to be defined
1 parent c173dce commit f1df71d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/index.js

Lines changed: 11 additions & 5 deletions
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

@@ -141,6 +141,7 @@ class TimerWrapper extends Component {
141141
render() {
142142
const {
143143
children,
144+
component,
144145
duration,
145146
} = this.props;
146147

@@ -160,16 +161,20 @@ class TimerWrapper extends Component {
160161
});
161162
});
162163

163-
return (
164-
<div {...cleanProps(this.props)}>
165-
{clonedChildren}
166-
</div>
164+
return React.createElement(component, {
165+
...cleanProps(this.props),
166+
},
167+
clonedChildren
167168
);
168169
}
169170
}
170171

171172
TimerWrapper.propTypes = {
172173
active: PropTypes.bool,
174+
component: PropTypes.oneOfType([
175+
PropTypes.element,
176+
PropTypes.string,
177+
]),
173178
duration: PropTypes.number,
174179
loop: PropTypes.bool,
175180
time: PropTypes.number,
@@ -180,6 +185,7 @@ TimerWrapper.propTypes = {
180185

181186
TimerWrapper.defaultProps = {
182187
active: false,
188+
component: 'div',
183189
duration: 10000,
184190
loop: false,
185191
time: 0,

0 commit comments

Comments
 (0)