diff --git a/src/sidebar.js b/src/sidebar.js index ca6444b7f4..60cab6650d 100755 --- a/src/sidebar.js +++ b/src/sidebar.js @@ -1,5 +1,4 @@ import React from 'react'; -import ReactDOM from 'react-dom'; const CANCEL_DISTANCE_ON_SCROLL = 20; @@ -75,6 +74,7 @@ class Sidebar extends React.Component { this.onTouchMove = this.onTouchMove.bind(this); this.onTouchEnd = this.onTouchEnd.bind(this); this.onScroll = this.onScroll.bind(this); + this.saveSidebarRef = this.saveSidebarRef.bind(this); } componentDidMount() { @@ -180,13 +180,17 @@ class Sidebar extends React.Component { } saveSidebarWidth() { - const width = ReactDOM.findDOMNode(this.refs.sidebar).offsetWidth; + const width = this.sidebar.offsetWidth; if (width !== this.state.sidebarWidth) { this.setState({sidebarWidth: width}); } } + saveSidebarRef(node) { + this.sidebar = node; + } + // calculate the sidebarWidth based on current touch info touchSidebarWidth() { // if the sidebar is open and start point of drag is inside the sidebar @@ -312,7 +316,7 @@ class Sidebar extends React.Component { return (