Skip to content

Commit 787d31e

Browse files
committed
format changes
1 parent c81378b commit 787d31e

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/components/TextLoop.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,13 @@ class TextLoop extends React.PureComponent<Props, State> {
9595
this.tickLoop = requestTimeout(this.tick, currentInterval);
9696
}, delay);
9797
} else {
98-
this.setState(
99-
(state, props) => {
100-
const { currentWordIndex } = state;
98+
this.setState((state, props) => {
99+
const { currentWordIndex: _currentWordIndex } = state;
101100

102-
return updatedState = {
101+
return {
103102
currentInterval: Array.isArray(props.interval)
104103
? props.interval[
105-
currentWordIndex % props.interval.length
104+
_currentWordIndex % props.interval.length
106105
]
107106
: props.interval,
108107
};

src/utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ declare global {
1010
}
1111
}
1212

13+
declare interface Handle {
14+
value: number | void;
15+
}
16+
1317
const requestAnimFrame = ((): Function => {
1418
if (typeof window !== "undefined") {
1519
return (
@@ -27,7 +31,7 @@ const requestAnimFrame = ((): Function => {
2731
return (): void => {};
2832
})();
2933

30-
export type RequestTimeout = number | void;
34+
export type RequestTimeout = object | number | void;
3135
/*
3236
* Behaves the same as setTimeout except uses requestAnimationFrame() where possible for better performance
3337
* @param {function} fn The callback function
@@ -52,7 +56,7 @@ export const requestTimeout = function(
5256

5357
const start = new Date().getTime();
5458

55-
const handle: object = new Object();
59+
const handle: Handle = { value: 0 };
5660

5761
function loop(): number | void {
5862
const current = new Date().getTime();

0 commit comments

Comments
 (0)