use-shopping-cart
use-shopping-cart copied to clipboard
Outdated example documentation for CartProvider stripe prop
EDIT see the first reply on this issue
As per the image, on SSR, there is a non-serializable value in the state.
If I understand it correctly, it is redux-persist
that is the root of this message, but that's a bit weird, since it seems to me that you have properly configured to ignore these messages here
To my knowledge, I am not using this lib in any unconventional way;
As per the error message, it's the stripe
prop, which is a promise, that is the offender. However, it seems to me that I am initiating the CartProvider
very much the same way as in the example
Also, please not this only happens during SSR.
Thanks,
Turned out there were more issues with this than just the SSR. Seems like the issue was the same as described here which is that the stripe
prop expects a Stripe API key as a string, and not a stripe promise.
There seems to be some stale documentation regarding this, more specfically in the Gatsby example
I will change the title of this issue accordingly
@GGAlanSmithee thank you for your feedback! I have a big workshop I'm presenting this week, once that's over with I can focus on addressing the issues you've raised. I really appreciate you!
@dayhaysoos
Awesome - thank you too! Hope your workshop turns out well.
To add some additional info, it actually seems like the SSR related issue persists, even after applying the above-mentioned fix. Since the checkout seems to be successfull, I haven't looked into it further, but the message is as before:
Let me know if you need additional info.
Hey @GGAlanSmithee, this is an issue that's okay to ignore for now. Just to be sure, this is an issue on Next JS, right? This doesn't show up on Gatsby as far as I know. I thought I applied logic well enough for ignoring anything redux-persist related when it comes to SSR but apparently, it's not working. If you're curious here's the context:
https://github.com/dayhaysoos/use-shopping-cart/blob/master/use-shopping-cart/core/index.js#L58
I'm gonna have someone take a look at this soon, I've been trying to figure it out for a while
@dayhaysoos
Thanks for your answer.
Yes, this is on next.js (haven't tested any other framework though).
Looking at the code you linked makes it even more weird. That conditional should def. return true in SSR (which I can confirm by debugging - typeof window === 'undefined'
).
PS. It doesn't seem like this warning appears in production, by running the app after statically generating it.
@GGAlanSmithee
I didn't know that this didn't show up for the production build, thanks for that!
Maybe my goal really should be just to hide the error. Not sure if Next has anything for that but I'm going to look into it
Any updates on this? The error creates a lot of noise in local development.
Hey @alec-bfa, unfortunately, no... But lemme make some time this weekend to actually get to the bottom of this, I'll keep y'all updated.
Hey y'all, I think I know how to fix it now, I made an issue #308 to document it. I'm also having a hard time testing the library locally and I think I want to redo the monorepo set up real quick, it'll help me move forward in the long run. Just keeping y'all in the loop!
I finally figured out the issue, it's going to be addressed in this PR of me switching to pnpm (not related lol)
#310
Closing this as I think I've finally solved it, but waiting to confirm later