| 155 | } |
| 156 | |
| 157 | componentDidUpdate(prevProps: Props) { |
| 158 | const { watch, watchFn = defaultOptions.watchFn, promise, promiseFn } = this.props |
| 159 | if (watch !== prevProps.watch) { |
| 160 | if (this.counter) this.cancel() |
| 161 | return this.load() |
| 162 | } |
| 163 | if ( |
| 164 | watchFn && |
| 165 | watchFn({ ...defaultOptions, ...this.props }, { ...defaultOptions, ...prevProps }) |
| 166 | ) { |
| 167 | if (this.counter) this.cancel() |
| 168 | return this.load() |
| 169 | } |
| 170 | if (promise !== prevProps.promise) { |
| 171 | if (this.counter) this.cancel() |
| 172 | if (promise) return this.load() |
| 173 | } |
| 174 | if (promiseFn !== prevProps.promiseFn) { |
| 175 | if (this.counter) this.cancel() |
| 176 | if (promiseFn) return this.load() |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | componentWillUnmount() { |
| 181 | this.cancel() |