@@ -34,6 +34,8 @@ export interface AntDesignWeb3ConfigProviderProps {
34
34
export const AntDesignWeb3ConfigProvider : React . FC <
35
35
React . PropsWithChildren < AntDesignWeb3ConfigProviderProps >
36
36
> = ( props ) => {
37
+ const mountRef = useRef ( false ) ;
38
+
37
39
const {
38
40
publicKey,
39
41
connected,
@@ -45,7 +47,6 @@ export const AntDesignWeb3ConfigProvider: React.FC<
45
47
} = useWallet ( ) ;
46
48
47
49
const { connection } = useConnection ( ) ;
48
-
49
50
const connectAsyncRef = useRef < ConnectAsync > ( ) ;
50
51
51
52
const [ balanceData , setBalanceData ] = useState < bigint > ( ) ;
@@ -98,6 +99,11 @@ export const AntDesignWeb3ConfigProvider: React.FC<
98
99
99
100
// connect/disconnect wallet
100
101
useEffect ( ( ) => {
102
+ // 初始化时跳过,避免与 WalletProvider 的自动连接逻辑冲突
103
+ if ( ! mountRef . current ) {
104
+ return ;
105
+ }
106
+
101
107
if ( wallet ?. adapter ?. name ) {
102
108
// if wallet is not ready, need clear selected wallet
103
109
if ( ! hasWalletReady ( wallet . adapter . readyState ) ) {
@@ -113,6 +119,12 @@ export const AntDesignWeb3ConfigProvider: React.FC<
113
119
}
114
120
} , [ wallet ?. adapter ?. name , connected ] ) ;
115
121
122
+ useEffect ( ( ) => {
123
+ if ( ! mountRef . current ) {
124
+ mountRef . current = true ;
125
+ }
126
+ } , [ ] ) ;
127
+
116
128
const chainList = useMemo ( ( ) => {
117
129
return props . availableChains
118
130
. map ( ( item ) => {
0 commit comments