adrianhajdin / ecommerce_sanity_stripe

Modern Full Stack ECommerce Application with Stripe
https://jsmastery.pro
2.19k stars 675 forks source link

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. #67

Open andremiracle opened 2 years ago

andremiracle commented 2 years ago

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

This error happened while generating the page. Any console logs will be displayed in the terminal window. Call Stack ReactDOMServerRenderer.render file:///C:/Users/Amarachukwu/Desktop/Levi/my%20projects/E-commerce/e-commerce/node_modules/react-dom/cjs/react-dom-server.node.development.js (4053:17) ReactDOMServerRenderer.read file:///C:/Users/Amarachukwu/Desktop/Levi/my%20projects/E-commerce/e-commerce/node_modules/react-dom/cjs/react-dom-server.node.development.js (3690:29) Object.renderToString file:///C:/Users/Amarachukwu/Desktop/Levi/my%20projects/E-commerce/e-commerce/node_modules/react-dom/cjs/react-dom-server.node.development.js (4298:27) Object.renderPage file:///C:/Users/Amarachukwu/Desktop/Levi/my%20projects/E-commerce/e-commerce/node_modules/next/dist/server/render.js (751:45) Object.defaultGetInitialProps file:///C:/Users/Amarachukwu/Desktop/Levi/my%20projects/E-commerce/e-commerce/node_modules/next/dist/server/render.js (389:51) Function.getInitialProps node_modules\next\dist\pages_document.js (145:19) Object.loadGetInitialProps file:///C:/Users/Amarachukwu/Desktop/Levi/my%20projects/E-commerce/e-commerce/node_modules/next/dist/shared/lib/utils.js (69:29) renderDocument file:///C:/Users/Amarachukwu/Desktop/Levi/my%20projects/E-commerce/e-commerce/node_modules/next/dist/server/render.js (764:48) Object.renderToHTML file:///C:/Users/Amarachukwu/Desktop/Levi/my%20projects/E-commerce/e-commerce/node_modules/next/dist/server/render.js (828:34) runMicrotasks

steisaden commented 1 year ago

I had the same error and was able to fix it by correcting my import module at the top of the file.

muskan-Bansal commented 1 year ago

try this in the StateContext.js file

const Context = createContext({});