Fix default "Pay with" chain (#4328)
## Problem solved
When supported source chains is updated, update `fromChain` to take the first chain on the supported sources list instead of defaulting to `polygon`
<!-- start pr-codex -->
---
## PR-Codex overview
The focus of this PR is to update the default source chain selection in `PayEmbed`.
### Detailed summary
- Updated default source chain selection logic in `BuyScreen.tsx`
- Refactored the dependencies array in `useEffect` hook for better performance
> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`
<!-- end pr-codex -->
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"thirdweb": patch
|
||||
---
|
||||
|
||||
Update default source chain selection in PayEmbed
|
||||
@@ -185,12 +185,22 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const supportedSources = supportedSourcesQuery.data;
|
||||
if (supportedSources[0]?.chain) {
|
||||
setFromChain(supportedSources[0]?.chain);
|
||||
}
|
||||
|
||||
return createSupportedTokens(
|
||||
supportedSourcesQuery.data,
|
||||
supportedSources,
|
||||
payOptions,
|
||||
props.supportedTokens,
|
||||
);
|
||||
}, [props.supportedTokens, supportedSourcesQuery.data, payOptions]);
|
||||
}, [
|
||||
props.supportedTokens,
|
||||
supportedSourcesQuery.data,
|
||||
payOptions,
|
||||
setFromChain,
|
||||
]);
|
||||
|
||||
const enabledPaymentMethods = useEnabledPaymentMethods({
|
||||
payOptions: props.payOptions,
|
||||
|
||||
Reference in New Issue
Block a user