useProductContext returning undefined the first time around

I am using useProductContext() in index.jsx in src. It returns ‘undefined’ the first time around and then it provides the correct value. Can someone tell me 1) why is useProductContext giving ‘undefined’ as the value the first time and 2) why is the function being called several times over…?

Thank you.

Does this recent thread answer your question? useProductContext() returning "undefined" when used in second module

1 Like