Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Hammer.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var HammerComponent = React.createClass({
},

componentDidMount: function () {
this.hammer = new Hammer(ReactDOM.findDOMNode(this));
this.hammer = new Hammer(this.domElement);
updateHammer(this.hammer, this.props);
},

Expand All @@ -126,6 +126,14 @@ var HammerComponent = React.createClass({
}
}, this);

var self = this;
props.ref = function(domElement) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JedWatson @gwu
cc @silentcloud
This PR will cause two problem:

  1. break change, see below use case, the children's string ref will be override by Hammer
        <Hammer
          direction="DIRECTION_HORIZONTAL"
          onPanStart={this.onPanStart}
          onPan={this.onPan}
          onPanEnd={this.onPanEnd}
        >
          <div className={`${prefixCls}-content`} ref="content">
            {children}
          </div>
        </Hammer>
  1. cause react warning: https://facebook.github.io/react/warnings/special-props.html

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Yes this is breaking ref for child components

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#87

if (self.props.ref) {
self.props.ref(domElement);
}
self.domElement = domElement;
};

// Reuse the child provided
// This makes it flexible to use whatever element is wanted (div, ul, etc)
return React.cloneElement(React.Children.only(this.props.children), props);
Expand Down