Skip to content

Commit c0e1956

Browse files
fix(throttle): Create throttled function on mount
1 parent 2e752ff commit c0e1956

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ class Geocoder extends PureComponent {
2929
value: this.props.value || null
3030
}
3131

32-
_throttledLoadOptions = throttle(this.loadOptions, this.props.rateLimit || 500)
33-
3432
cacheOptions (options) {
3533
options.forEach((o) => {
3634
this.options[o.value] = o.feature
3735
})
3836
}
3937

38+
componentWillMount () {
39+
this._throttledLoadOptions = throttle(this.loadOptions, this.props.rateLimit || 500)
40+
}
41+
4042
componentWillReceiveProps (nextProps) {
4143
if (!shallowEqual(nextProps.value, this.props.value)) {
4244
this.setState({value: nextProps.value})

0 commit comments

Comments
 (0)