Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 66d8d32

Browse files
committed
fix(context): fix problem which unmount comp after location change in AsyncRegionList
1 parent 9007928 commit 66d8d32

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

‎packages/console-utils/xconsole-context/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alicloud/xconsole-context",
3-
"version": "2.5.1",
3+
"version": "2.5.2",
44
"main": "lib/index.js",
55
"module": "es/index.js",
66
"types": "lib/index.d.ts",

‎packages/console-utils/xconsole-context/src/withConsoleContext.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState, useRef } from 'react';
1+
import React, { useEffect, useLayoutEffect,useState, useRef } from 'react';
22
import isFunction from 'lodash/isFunction';
33
import { matchPath } from 'react-router-dom';
44
import ConsoleBaseMessengerRegion from '@alicloud/console-base-rc-messenger-region';
@@ -90,12 +90,22 @@ function withAsyncRegionList<P extends IConsoleContextProp>(
9090

9191
const { customPaths = [] } = appConfig?.aplus || {};
9292

93-
useEffect(() => {
93+
useLayoutEffect(() => {
9494
(async () => {
9595
if (isFunction(userRegionListConfig)) {
96-
setLoading(true);
9796
const regions = await (userRegionListConfig as (location) => Promise<IPayloadRegion[]>)(props.location);
98-
setRegionList(regions);
97+
setRegionList((curRegions) => {
98+
// diff regions
99+
try {
100+
if (JSON.stringify(curRegions) !== JSON.stringify(regions)) {
101+
return regions;
102+
}
103+
} catch (e) {
104+
console.error('The regionList from is not valid.');
105+
}
106+
107+
return curRegions;
108+
});
99109
setLoading(false);
100110
}
101111
})();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /