Open kalpitrathore1 opened 2 weeks ago
+1 to this one! In my case, my console.log() is just placed at the start of component and also gets printed multiple times:
export default reactExtension('purchase.checkout.block.render', () => <Component />)
const Component = () => {
console.log('ENTRY POINT')
return <></>
}
Just wondering if it's a bug or I'm missing something
A little update: after I completely removed every hook from a component it now renders only once. I guess in my case it might be a Shopify's useCartLines()
hook that:
Returns the current line items for the checkout, and automatically re-renders your component if line items are added, removed, or updated.
So my advice to go through your hooks to see if this is actually intended
A little update: after I completely removed every hook from a component it now renders only once. I guess in my case it might be a Shopify's
useCartLines()
hook that:Returns the current line items for the checkout, and automatically re-renders your component if line items are added, removed, or updated.
So my advice to go through your hooks to see if this is actually intended
Hey @developerdevit
We need access to shipping addresses for specific use cases, so we've implemented hooks to manage this so can't remove them.
Hello guys,
I'm encountering an issue with the checkout UI extensions where my extension point is being re-rendered multiple times. This behavior is impacting the user experience for my app, as the unnecessary re-renders cause a disruptive interface.
I've attached the code snippet and a video for better visualization.
Code Overview
The main functionality here involves a React component within a Shopify app, designed to render some UI before the shipping options list during checkout. The component,
Print
, uses Shopify'suseShippingAddress
hook to access the current shipping address. When the shipping address changes, thePrint
component is intended to log a message to the console.However, due to frequent re-renders, the
console.log
in thePrint
component’suseEffect
hook is firing multiple times. This re-rendering issue creates unwanted logging and impacts the app's UX by making the interface feel less stable or responsive.Code Snippet
address.jsx
package.json
video.mp4 https://github.com/user-attachments/assets/1dde486e-ecc7-4eb0-9a5f-622c0342ccc2
If you see in the video above, Console is getting printed 6 times