Issue with useApplyCartLinesChange and useCartLines in Shopify Checkout Extension

I’m developing a Shopify Checkout Extension and encountering a strange behavior when using useApplyCartLinesChange and useCartLines.

Problem Description:

  1. What I’m doing:

    • I’m using useApplyCartLinesChange to add a product to the cart when a button is clicked.
    • useCartLines is used to retrieve the current cart line data.
  2. What works:

    • useCartLines correctly fetches the cart line data when the checkout page loads.
  3. The issue:

    • After calling useApplyCartLinesChange to update the cart (e.g., add a product), the cart updates for a moment, but then automatically reverts to the old state in useCartLines.

Expected Behavior:

  • After useApplyCartLinesChange is called, useCartLines should reflect the updated cart state.

What I’ve Tried:

  • Verified the logic for useApplyCartLinesChange.
  • Ensured the product is successfully added to the cart (the UI briefly reflects the addition before reverting).
  • Checked if any state management or caching is interfering.

Questions:

  1. Is there a specific mechanism required to sync useCartLines with the updated cart state after calling useApplyCartLinesChange?
  2. Could this be an issue with how Shopify propagates cart updates in the checkout extension?

Any insights, code samples, or documentation references would be greatly appreciated