use-shopping-cart icon indicating copy to clipboard operation
use-shopping-cart copied to clipboard

Outdated example documentation for CartProvider stripe prop

Open GGAlanSmithee opened this issue 3 years ago • 6 comments

EDIT see the first reply on this issue

As per the image, on SSR, there is a non-serializable value in the state.

image

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;

image

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,

GGAlanSmithee avatar Sep 08 '21 05:09 GGAlanSmithee

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 avatar Sep 08 '21 06:09 GGAlanSmithee

@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 avatar Sep 13 '21 20:09 dayhaysoos

@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:

image

Let me know if you need additional info.

GGAlanSmithee avatar Sep 15 '21 06:09 GGAlanSmithee

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 avatar Sep 19 '21 19:09 dayhaysoos

@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 avatar Sep 20 '21 04:09 GGAlanSmithee

@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

dayhaysoos avatar Sep 20 '21 20:09 dayhaysoos

Any updates on this? The error creates a lot of noise in local development.

alec-bfa avatar Mar 03 '23 06:03 alec-bfa

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.

dayhaysoos avatar Mar 03 '23 06:03 dayhaysoos

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!

dayhaysoos avatar Mar 04 '23 21:03 dayhaysoos

I finally figured out the issue, it's going to be addressed in this PR of me switching to pnpm (not related lol)

#310

dayhaysoos avatar Mar 05 '23 15:03 dayhaysoos

Closing this as I think I've finally solved it, but waiting to confirm later

dayhaysoos avatar Mar 19 '23 19:03 dayhaysoos