-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple execution of the checkout UI extension #1006
Comments
Pretty sure this is due to the fact that react re-renders whenever the extension api updates (ie: changing line items, changing shipping methods, etc) Just make sure you place things that only run once with useEffect or useState to manage re-renders. |
Thanks @gil-- I don't think it is because of the react re-render but rather the render entry point got called multiple times. I'm also seeing that the |
I'm using versions I'm rendering the extension on 3 targets The Checkout Information and Order Status extensions are only loading once but the Thank You extension is always being loaded twice. I have even removed the Checkout Information and Order Status extensions and the Thank You extension is always being rendered twice. I have pared back the App to the code below and it's still rendering twice. const App = (props) => {
useEffect(() => {
console.log(process.env.NODE_ENV);
}, []);
return (
<BlockStack
border="base"
padding="base"
borderRadius="base"
spacing="tight"
>
<Text>Test</Text>
</BlockStack>
);
}; |
It looks like the other pages are fixed. However, it seems the Thank You Page is still having issue with rendering twice. See #1435 |
Ah ok, thanks for linking the issue @philieurokt 👍 |
Just found a walk around using https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/react-hooks/metadata/useextension If we do logic when the The rendered object's type is |
Is there a way to avoid the pre-render instead? |
I'm still facing the same issue with the "purchase.thank-you.block.render" target. We're ready to deploy an extension to one of our live apps, but we're encountering a problem where the component renders twice. This is causing a significant issue for us as we use an External API to dynamically populate the UI components of our extension, and the double render results in two API requests almost simultaneously. I've tested this with other targets and confirmed that this double rendering issue seems unique to the "purchase.thank-you.block.render" target. Is there a reason for this behavior that I might be overlooking, or is this a bug? |
@jackthedev have you fix it ? I have same issue, causing it to do multiple request in our api simultaneously. |
Same issue, double rendering causes redundant API calls. Having a configuration setting to turn it off would be great. |
Facing same issue, I am using 'purchase.checkout.block.render' as extension target. |
Anyone find a solution here? |
Please list the package(s) involved in the issue, and include the version you are using
We are using "@shopify/checkout-ui-extensions-react": "^0.26.2"
Describe the bug
Steps to reproduce the behavior:
Checkout::Dynamic::Render
. Something like belowExpected behavior
Since I only add the extension once to the payment page, I would expect the extension to execute only once.
The extension we are developing needs to make network calls. Thus, it is not ideal to have it run on every checkout page other than the one the extension is added to.
I also can't find a way to detect the current checkout step the execution is running on.
Screenshots
I can see at least three executions of the extension when going through the checkout pages and landed on the payment page (see below). The extension is only shown on the payment page.
Sometimes, I can see it run twice in the payment page as well.
Additional context
I'm testing the extension on a development store with the extension preview feature enabled.
The text was updated successfully, but these errors were encountered: