I’m trying to add a custom field for each shipping method in the Checkout UI. The problem arises when rendering components at the position “purchase.checkout.shipping-option-item.render-after” simultaneously.
These components need to calculate and retrieve custom field information using the useStorage hook. However, since useStorage is asynchronous, the data might not be in sync when these components render together, leading to incorrect calculations.
For example, let’s say there are three components (1, 2, and 3). Each one reads from and writes to storage. Because they’re rendered simultaneously by default, the storage state might not reflect the most recent values, which can cause errors in the calculations.
The core issue: The asynchronous nature of useStorage means that when component 2 is rendering, the writing process in component 1 might not be finished, so component 2 can’t access the updated value that component 1 wrote.
How can I handle this asynchronous issue to ensure that each component has access to the most up-to-date storage values during rendering?
