(prevProps: Props, prevState: State)
| 80 | } |
| 81 | |
| 82 | componentDidUpdate(prevProps: Props, prevState: State): void { |
| 83 | const { interval, children, delay } = this.props as Props; |
| 84 | const { currentWordIndex } = this.state; |
| 85 | |
| 86 | const currentInterval = Array.isArray(interval) |
| 87 | ? interval[currentWordIndex % interval.length] |
| 88 | : interval; |
| 89 | |
| 90 | if (prevState.currentInterval !== currentInterval) { |
| 91 | this.clearTimeouts(); |
| 92 | |
| 93 | if (currentInterval > 0 && React.Children.count(children) > 1) { |
| 94 | this.tickDelay = requestTimeout(() => { |
| 95 | this.tickLoop = requestTimeout(this.tick, currentInterval); |
| 96 | }, delay); |
| 97 | } else { |
| 98 | this.setState((state, props) => { |
| 99 | const { currentWordIndex: _currentWordIndex } = state; |
| 100 | |
| 101 | return { |
| 102 | currentInterval: Array.isArray(props.interval) |
| 103 | ? props.interval[ |
| 104 | _currentWordIndex % props.interval.length |
| 105 | ] |
| 106 | : props.interval, |
| 107 | }; |
| 108 | }); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | if (!isEqual(prevProps.children, children)) { |
| 113 | // eslint-disable-next-line react/no-did-update-set-state |
| 114 | this.setState({ |
| 115 | elements: React.Children.toArray(children), |
| 116 | }); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | componentWillUnmount(): void { |
| 121 | this.isUnMounting = true; |
nothing calls this directly
no test coverage detected