MCPcopy
hub / github.com/baidu/amis / componentDidMount

Method componentDidMount

packages/amis/src/renderers/Wizard.tsx:250–329  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

248 };
249
250 componentDidMount() {
251 const {
252 initApi,
253 initFetch,
254 initAsyncApi,
255 initFinishedField,
256 store,
257 messages: {fetchSuccess, fetchFailed},
258 onInit
259 } = this.props;
260
261 if (isEffectiveApi(initApi, store.data, initFetch)) {
262 store
263 .fetchInitData(initApi, store.data, {
264 successMessage: fetchSuccess,
265 errorMessage: fetchFailed,
266 onSuccess: () => {
267 if (
268 !isEffectiveApi(initAsyncApi, store.data) ||
269 store.data[initFinishedField || 'finished']
270 ) {
271 return;
272 }
273
274 return until(
275 () => store.checkRemote(initAsyncApi, store.data),
276 (ret: any) => ret && ret[initFinishedField || 'finished'],
277 cancel => (this.asyncCancel = cancel)
278 );
279 }
280 })
281 .then(result => {
282 this.handleFetchInitEvent(result);
283
284 const state = {
285 currentStep:
286 typeof this.props.startStep === 'string'
287 ? toNumber(
288 tokenize(
289 this.props.startStep,
290 createObject(this.props.data, result?.data || {})
291 ),
292 1
293 )
294 : 1
295 };
296
297 if (
298 result &&
299 result.data &&
300 (typeof result.data.step === 'number' ||
301 (typeof result.data.step === 'string' &&
302 /^\d+$/.test(result.data.step)))
303 ) {
304 state.currentStep = toNumber(result.data.step, 1);
305 }
306
307 this.setState(state, () => {

Callers

nothing calls this directly

Calls 8

handleFetchInitEventMethod · 0.95
checkSubmitMethod · 0.95
normalizeStepsMethod · 0.95
isEffectiveApiFunction · 0.90
untilFunction · 0.90
toNumberFunction · 0.90
tokenizeFunction · 0.90
createObjectFunction · 0.90

Tested by

no test coverage detected