Skip to content

Commit a8da481

Browse files
committed
perf: ⚡️ upgrade throttle-debounce lib, fix tests after refactor
1 parent c050afd commit a8da481

File tree

11 files changed

+17
-17
lines changed

11 files changed

+17
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"semantic-release": "semantic-release"
2929
},
3030
"dependencies": {
31-
"throttle-debounce": "^1.0.1",
31+
"throttle-debounce": "^2.0.1",
3232
"nano-css": "^1.13.0",
3333
"screenfull": "^3.3.2",
3434
"fast-af": "^0.1.0",

src/IdleSensor/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Component} from 'react';
22
import {render, createEnhancer} from 'react-universal-interface';
33
import {on, off, noop} from '../util';
4-
import * as throttle from 'throttle-debounce/throttle';
4+
import {throttle} from 'throttle-debounce';
55

66
const equalSets = (a: string[], b: string[]) => {
77
if (a.length !== b.length) {

src/LocalStorage/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component} from 'react';
22
import {get, set, del} from './local-storage';
3-
const debounce = require('throttle-debounce/debounce');
3+
import {debounce} from 'throttle-debounce';
44

55
export interface ILocalStorageProps {
66
name: string;

src/Parallax/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {render} from 'react-universal-interface';
33
import {IUniversalInterfaceProps} from '../typing';
44
import {noop, on, off} from '../util';
55
import {getElRect, getRootRect, TRect} from '../ViewportScrollSensor';
6-
const throttle = require('throttle-debounce/throttle');
6+
import {throttle} from 'throttle-debounce';
77

88
const zeros: TRect = [0, 0, 0, 0];
99

src/Slider/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import {noop, on, off} from '../util';
33
import renderProp from '../util/renderProp';
4-
const throttle = require('throttle-debounce/throttle');
4+
import {throttle} from 'throttle-debounce';
55

66
export interface ISliderProps {
77
children?: React.ReactElement<any> | ((state: ISliderState) => React.ReactElement<any>);

src/SyncSensor/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {Component} from 'react';
1+
import * as React from 'react';
22
import {noop} from '../util';
33
import renderProp from '../util/renderProp';
4-
import * as throttle from 'throttle-debounce/throttle';
4+
import {throttle} from 'throttle-debounce';
55

66
export interface ISyncSensorProps<TState> {
77
throttle?: number;
@@ -13,7 +13,7 @@ export interface ISyncSensorProps<TState> {
1313
onEvent: (event) => TState;
1414
}
1515

16-
export class SyncSensor<TState> extends Component<ISyncSensorProps<TState>, TState> {
16+
export class SyncSensor<TState> extends React.Component<ISyncSensorProps<TState>, TState> {
1717
static defaultProps = {
1818
throttle: 100
1919
};

src/ViewportScrollSensor/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component, cloneElement, SFCElement} from 'react';
22
import {on, off, noop} from '../util';
3-
import * as throttle from 'throttle-debounce/throttle';
3+
import {throttle} from 'throttle-debounce';
44
import renderProp from '../util/renderProp';
55
import {IUniversalInterfaceProps} from '../typing';
66

src/WindowScrollSensor/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component} from 'react';
1+
import * as React from 'react';
22
import {SyncSensor} from '../SyncSensor';
33
import {isClient, h} from '../util';
44
import faccToHoc from '../util/faccToHoc';
@@ -36,7 +36,7 @@ const getInitialState = () => {
3636
}
3737
};
3838

39-
export class WindowScrollSensor extends Component<IWindowScrollSensorProps, any> {
39+
export class WindowScrollSensor extends React.Component<IWindowScrollSensorProps, any> {
4040
initial = getInitialState();
4141

4242
render () {

src/WindowWidthSensor/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import faccToHoc from '../util/faccToHoc';
44
import renderProp from '../util/renderProp';
55
import {IUniversalInterfaceProps} from '../typing'
66
import {noop, on, off} from '../util';
7-
const throttle = require('throttle-debounce/throttle');
7+
import {throttle} from 'throttle-debounce';
88

99
export interface IWindowWidthSensorProps extends IUniversalInterfaceProps<IWindowWidthSensorState> {
1010
width?: number,

src/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {createElement} from 'react';
1+
import * as React from 'react';
22

33
export type TComponent<TProps> = React.ComponentClass<TProps> | React.StatelessComponent<TProps>;
44
export type THoc<P1, P2> = (Comp: TComponent<P1>) => TComponent<P2>
@@ -29,4 +29,4 @@ export const sym = (name) => {
2929

3030
export const isFn = (fn) => typeof fn === 'function';
3131

32-
export const h = createElement as any;
32+
export const h = React.createElement;

0 commit comments

Comments
 (0)