Skip to content

Commit f507cd9

Browse files
committed
Replaces lodash.throttle and lodash.debounce with throttle-debounce
1 parent 82649da commit f507cd9

4 files changed

Lines changed: 11 additions & 17 deletions

File tree

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@
3434
"dependencies": {
3535
"element-resize-detector": "^1.1.15",
3636
"invariant": "^2.2.4",
37-
"lodash.debounce": "^4.0.8",
38-
"lodash.throttle": "^4.1.1",
39-
"shallowequal": "^1.1.0"
37+
"shallowequal": "^1.1.0",
38+
"throttle-debounce": "^2.1.0"
4039
},
4140
"peerDependencies": {
4241
"prop-types": "^15.0.0-0",

rollup.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ module.exports = {
88
external: [
99
'element-resize-detector',
1010
'invariant',
11-
'lodash.debounce',
12-
'lodash.throttle',
11+
'throttle-debounce',
1312
'prop-types',
1413
'react-dom',
1514
'react',

src/with-size.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import React, { Children, Component } from 'react'
66
import PropTypes from 'prop-types'
77
import ReactDOM from 'react-dom'
88
import invariant from 'invariant'
9-
import throttle from 'lodash.throttle'
10-
import debounce from 'lodash.debounce'
9+
import { debounce, throttle } from 'throttle-debounce'
1110
import resizeDetector from './resize-detector'
1211

1312
const errMsg =
@@ -288,7 +287,7 @@ function withSize(config = defaultConfig) {
288287
)
289288
}
290289

291-
checkIfSizeChanged = refreshDelayStrategy(el => {
290+
checkIfSizeChanged = refreshDelayStrategy(refreshRate, el => {
292291
const {
293292
width,
294293
height,
@@ -307,7 +306,7 @@ function withSize(config = defaultConfig) {
307306
if (this.hasSizeChanged(this.strategisedGetState(), next)) {
308307
this.strategisedSetState(next)
309308
}
310-
}, refreshRate)
309+
})
311310

312311
render() {
313312
const disablePlaceholder =

yarn.lock

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4041,10 +4041,6 @@ locate-path@^2.0.0:
40414041
p-locate "^2.0.0"
40424042
path-exists "^3.0.0"
40434043

4044-
lodash.debounce@^4.0.8:
4045-
version "4.0.8"
4046-
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
4047-
40484044
lodash.escape@^4.0.1:
40494045
version "4.0.1"
40504046
resolved "https://registry.yarnpkg.com/lodash.escape/-/lodash.escape-4.0.1.tgz#c9044690c21e04294beaa517712fded1fa88de98"
@@ -4065,10 +4061,6 @@ lodash.sortby@^4.7.0:
40654061
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
40664062
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
40674063

4068-
lodash.throttle@^4.1.1:
4069-
version "4.1.1"
4070-
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
4071-
40724064
lodash@^4.15.0, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.17.5:
40734065
version "4.17.11"
40744066
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
@@ -5977,6 +5969,11 @@ throat@^4.0.0:
59775969
resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a"
59785970
integrity sha1-iQN8vJLFarGJJua6TLsgDhVnKmo=
59795971

5972+
throttle-debounce@^2.1.0:
5973+
version "2.1.0"
5974+
resolved "https://registry.yarnpkg.com/throttle-debounce/-/throttle-debounce-2.1.0.tgz#257e648f0a56bd9e54fe0f132c4ab8611df4e1d5"
5975+
integrity sha512-AOvyNahXQuU7NN+VVvOOX+uW6FPaWdAOdRP5HfwYxAfCzXTFKRMoIMk+n+po318+ktcChx+F1Dd91G3YHeMKyg==
5976+
59805977
through@^2.3.6:
59815978
version "2.3.8"
59825979
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"

0 commit comments

Comments
 (0)