Skip to content

Commit

Permalink
fix: issue causing recursive depth exception in react (#1088)
Browse files Browse the repository at this point in the history
  • Loading branch information
moldy530 authored Oct 17, 2024
1 parent f586e1d commit 7b61fd6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions account-kit/core/src/store/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe("createConfig tests", () => {
"status": "INITIALIZING",
},
},
"version": 12,
"version": 13,
}
`);
});
Expand Down Expand Up @@ -173,7 +173,7 @@ describe("createConfig tests", () => {
"status": "INITIALIZING",
},
},
"version": 12,
"version": 13,
}
`);
});
Expand Down
14 changes: 8 additions & 6 deletions account-kit/core/src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,20 @@ export const createAccountKitStore = (
},
reviver: (key, value) => {
if (key === "chain") {
return (
connections.find(
(c) => c.chain.id === (value as { id: number }).id
)?.chain ?? connections[0].chain
);
return connections.find(
(c) => c.chain.id === (value as { id: number }).id
)?.chain;
}

return storeReviver(key, value);
},
}),
merge: (persisted, current) => {
const persistedState = persisted as StoreState;
if (persistedState.chain == null) {
return createInitialStoreState(params);
}

const connectionsMap = createConnectionsMap(connections);
if (!connectionsMap.has(persistedState.chain.id)) {
return createInitialStoreState(params);
Expand All @@ -107,7 +109,7 @@ export const createAccountKitStore = (
skipHydration: ssr,
partialize: ({ signer, accounts, ...writeableState }) =>
writeableState,
version: 12,
version: 13,
})
: () => createInitialStoreState(params)
)
Expand Down

0 comments on commit 7b61fd6

Please sign in to comment.