Skip to content

Commit

Permalink
Use ref instead of findDOMNode also in BaseDisplayObject. Removed rea…
Browse files Browse the repository at this point in the history
…ct-dom dependency.
  • Loading branch information
okonet committed Nov 11, 2015
1 parent 2b98def commit bfc3dfe
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/BaseDisplayObject.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

import React from 'react';
import ReactDOM from 'react-dom';

export default class BaseDisplayObject extends React.Component {

Expand All @@ -28,8 +27,7 @@ export default class BaseDisplayObject extends React.Component {

onDrag(e) {
if(this.props.dragManager){
var domNode = ReactDOM.findDOMNode(this);
this.props.dragManager.startDrag(e, domNode, this.props.item, this.updateDrag.bind(this));
this.props.dragManager.startDrag(e, this.domNode, this.props.item, this.updateDrag.bind(this));
}
}

Expand All @@ -52,9 +50,9 @@ export default class BaseDisplayObject extends React.Component {

componentDidMount() {
if(this.props.dragEnabled){
ReactDOM.findDOMNode(this).addEventListener('mousedown', this.onDrag);
ReactDOM.findDOMNode(this).addEventListener('touchstart', this.onDrag);
ReactDOM.findDOMNode(this).setAttribute('data-key', this.props.key);
this.domNode.addEventListener('mousedown', this.onDrag);
this.domNode.addEventListener('touchstart', this.onDrag);
this.domNode.setAttribute('data-key', this.props.key);
}
}

Expand All @@ -64,7 +62,7 @@ export default class BaseDisplayObject extends React.Component {

render() {
return (
<div style={this.getStyle()}>{ this.props.children }</div>
<div ref={node => this.domNode = node} style={this.getStyle()}>{ this.props.children }</div>
);
}
}
Expand Down

0 comments on commit bfc3dfe

Please sign in to comment.