Skip to content

Commit

Permalink
Use ref instead of findDOMNode
Browse files Browse the repository at this point in the history
  • Loading branch information
bezenson committed Nov 3, 2017
1 parent 95a1e41 commit 26a5db8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import Odometer from 'odometer';

export default class ReactOdometer extends Component {
static defaultProps = {
options: {},
};

static propTypes = {
value: PropTypes.number.isRequired,
options: PropTypes.object,
};

componentDidMount() {
const { value, options } = this.props;
this.odometer = new Odometer({
el: ReactDOM.findDOMNode(this),
value: this.props.value,
...this.props.options,
el: this.node,
value,
...options,
});
}

Expand All @@ -22,6 +26,10 @@ export default class ReactOdometer extends Component {
}

render() {
return React.createElement('div');
return React.createElement('div', {
ref: (node) => {
this.node = node;
},
});
}
}

0 comments on commit 26a5db8

Please sign in to comment.