Replies: 1 comment 2 replies
-
Maybe you're missing passing cc @blittle |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I am fairly new to Hydrogen and somewhat to Remix/React. I am experimenting with the useOptimisticCart hook that has been released recently and have run into some problems (might be related to a lack of understanding).
I have upgraded using the upgrade/migration guide you have provided
My code consists of a header that is called in the layout.tsx which is called from the root.tsx, it contains a CartMenu based on the Popover from shadcn
CartPopover.tsx
Header.tsx
The main issue is that the code always returns the
<div>Cart is empty..</div>
element.The console log however prints (firefox)

This indicates that
Now I assume it is due to the nature of promises, that it gets logged to the console after the UI is rendered, but shouldn't it cause a re-render when the promise returns. And is the idea of the OptimisticCart that it renders immediately and we don't have to wait for the promise to return?
The result is the same no matter where I specify the code even directly in the root.tsx.
I feel like I might be doing some basic thing wrong, but I have been stuck on this since it was released and am at my wits end.
Link to my repository if it is of any help!
Best regards!
Edit 1:
Adding a console.log() we can see that it enters the mapping function at some point, but doesn't render anything as it logs the line.id.
Beta Was this translation helpful? Give feedback.
All reactions