Skip to content

Commit c81378b

Browse files
authored
fix state.currentInterval not updated when 0
1 parent 7bcaa5b commit c81378b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/components/TextLoop.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@ class TextLoop extends React.PureComponent<Props, State> {
9494
this.tickDelay = requestTimeout(() => {
9595
this.tickLoop = requestTimeout(this.tick, currentInterval);
9696
}, delay);
97+
} else {
98+
this.setState(
99+
(state, props) => {
100+
const { currentWordIndex } = state;
101+
102+
return updatedState = {
103+
currentInterval: Array.isArray(props.interval)
104+
? props.interval[
105+
currentWordIndex % props.interval.length
106+
]
107+
: props.interval,
108+
};
109+
});
97110
}
98111
}
99112

0 commit comments

Comments
 (0)