MCPcopy Create free account
hub / github.com/async-library/react-async / componentDidUpdate

Method componentDidUpdate

packages/react-async/src/Async.tsx:157–178  ·  view source on GitHub ↗
(prevProps: Props)

Source from the content-addressed store, hash-verified

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()

Callers

nothing calls this directly

Calls 3

cancelMethod · 0.95
loadMethod · 0.95
watchFnFunction · 0.85

Tested by

no test coverage detected