Skip to content

Commit a92b422

Browse files
committed
Make the throttled version of onContentHeight once
1 parent 97ffdc4 commit a92b422

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

index.ios.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ var HTMLWebView = React.createClass({
3535
autoHeight: PropTypes.bool
3636
},
3737

38+
componentWillMount: function () {
39+
this.onContentHeight = _.throttle(this.onContentHeight, 300);
40+
},
41+
3842
shouldComponentUpdate: function (nextProps, nextState) {
3943
return !_.isEqual(nextProps, this.props) || !_.isEqual(nextState, this.state);
4044
},
@@ -54,7 +58,6 @@ var HTMLWebView = React.createClass({
5458
this._currentMakeSafe = this.props.makeSafe;
5559
this._safeHtml = this.safeHtml(this._currentHtml);
5660
}
57-
var updateContentHeight = _.throttle(this.onContentHeight, 100);
5861
return (
5962
<_HTMLWebView
6063
style={[{height: this.state.contentHeight}, this.props.style]}
@@ -64,7 +67,7 @@ var HTMLWebView = React.createClass({
6467
onContentHeight={(e) => {
6568
this.contentHeight = e.nativeEvent.contentHeight;
6669
if (this.props.autoHeight && this.contentHeight > 1) {
67-
updateContentHeight();
70+
this.onContentHeight();
6871
}
6972
}} />
7073
);

0 commit comments

Comments
 (0)