gioboa / qwik-dream-demo

https://qwik-dream-demo.pages.dev/
28 stars 11 forks source link

Cannot read `lines` of `null` #31

Closed dario-piotrowicz closed 1 year ago

dario-piotrowicz commented 1 year ago

Some times in the app we can get a console error: Screenshot 2022-12-07 at 20 06 41

I think that the issue is simply that the lines of activeOrder can be null: Screenshot 2022-12-07 at 20 06 32

I think should be very straightforward to fix, just by putting a check here: https://github.com/gioboa/qwik-dream-demo/blob/29eac27f8b7c667d46d0d22101ce08444f5a43fa/apps/cart/src/routes/index.tsx#L18 like:

- const productVariantQuantities = data.activeOrder.lines.reduce((result: any, line: any) => ({
+ const productVariantQuantities = (data.activeOrder.lines ?? []).reduce((result: any, line: any) => ({
gioboa commented 1 year ago

With my last commit I fixed it like this https://github.com/gioboa/qwik-dream-demo/blob/8fae837f2964958fe756ef10b84bb169d729d378/apps/cart/src/routes/index.tsx#L17

dario-piotrowicz commented 1 year ago

cool, sorry I missed it :slightly_smiling_face::+1: