TypeError: Cannot destructure property ‘shippingInfo’ of ‘order’ as it is undefined.
Hello,
I’m Nasir Shoyas
I’m getting ( TypeError: Cannot destructure property ‘shippingInfo’ of ‘order’ as it is undefined.) can anyone help me with this?
Here is my code and output:
All information from Database:
Well, if it’s undefined there’s nothing to destructure, so you need to only try to do that if you know there’s an object there. You can’t try to access object properties before that object exists.
Your selector on line 14 aknowledges that state.orderDetails may not exist, and provides an empty object as a default. In order to stop getting the type error, the rest of your code needs to follow that same principle of handling the case where order is an empty object.
Thanks a lot for giving you effort, ArielLeslie and DanCouper
Line 14: state.orderDetails is not exist. That’s why it returns undefined. But, I’ve done same method of code for other component then it worked. Why line 14 does not exist? I cann’t understand…
Here I’m sharing my full code of this component. So that you can find the actual mistake of mine.
At least I can solve this issue by myself.
I’m describing about this error:
OrderDetail part -1 : Line 15
order needs an empty string. without empty string order gets just prototype.
just watch the pic u can understand clearly: